gRPC  0.6.0
 All Classes Namespaces Functions Variables Enumerations Properties Pages
php_grpc.h
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 
35 #ifndef PHP_GRPC_H
36 #define PHP_GRPC_H
37 
38 #include <stdbool.h>
39 
40 extern zend_module_entry grpc_module_entry;
41 #define phpext_grpc_ptr &grpc_module_entry
42 
43 #define PHP_GRPC_VERSION \
44  "0.1.0" /* Replace with version number for your extension */
45 
46 #ifdef PHP_WIN32
47 #define PHP_GRPC_API __declspec(dllexport)
48 #elif defined(__GNUC__) && __GNUC__ >= 4
49 #define PHP_GRPC_API __attribute__((visibility("default")))
50 #else
51 #define PHP_GRPC_API
52 #endif
53 
54 #ifdef ZTS
55 #include "TSRM.h"
56 #endif
57 
58 #include "php.h"
59 
60 #include "grpc/grpc.h"
61 
62 #define RETURN_DESTROY_ZVAL(val) \
63  RETURN_ZVAL(val, false /* Don't execute copy constructor */, \
64  true /* Dealloc original before returning */)
65 
66 /* These are all function declarations */
67 /* Code that runs at module initialization */
68 PHP_MINIT_FUNCTION(grpc);
69 /* Code that runs at module shutdown */
70 PHP_MSHUTDOWN_FUNCTION(grpc);
71 /* Displays information about the module */
72 PHP_MINFO_FUNCTION(grpc);
73 
74 /*
75  Declare any global variables you may need between the BEGIN
76  and END macros here:
77 
78 ZEND_BEGIN_MODULE_GLOBALS(grpc)
79 ZEND_END_MODULE_GLOBALS(grpc)
80 */
81 
82 /* In every utility function you add that needs to use variables
83  in php_grpc_globals, call TSRMLS_FETCH(); after declaring other
84  variables used by that function, or better yet, pass in TSRMLS_CC
85  after the last function argument and declare your utility function
86  with TSRMLS_DC after the last declared argument. Always refer to
87  the globals in your function as GRPC_G(variable). You are
88  encouraged to rename these macros something shorter, see
89  examples in any other php module directory.
90 */
91 
92 #ifdef ZTS
93 #define GRPC_G(v) TSRMG(grpc_globals_id, zend_grpc_globals *, v)
94 #else
95 #define GRPC_G(v) (grpc_globals.v)
96 #endif
97 
98 #endif /* PHP_GRPC_H */