czmq-ffi-gen 0.13.0-x86-mingw32 → 0.14.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +13 -0
  3. data/lib/czmq-ffi-gen/czmq/ffi.rb +224 -698
  4. data/lib/czmq-ffi-gen/czmq/ffi/zactor.rb +40 -7
  5. data/lib/czmq-ffi-gen/czmq/ffi/zargs.rb +259 -0
  6. data/lib/czmq-ffi-gen/czmq/ffi/zarmour.rb +3 -3
  7. data/lib/czmq-ffi-gen/czmq/ffi/zcert.rb +15 -6
  8. data/lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb +25 -11
  9. data/lib/czmq-ffi-gen/czmq/ffi/zchunk.rb +18 -18
  10. data/lib/czmq-ffi-gen/czmq/ffi/zclock.rb +6 -6
  11. data/lib/czmq-ffi-gen/czmq/ffi/zconfig.rb +27 -17
  12. data/lib/czmq-ffi-gen/czmq/ffi/zdigest.rb +4 -4
  13. data/lib/czmq-ffi-gen/czmq/ffi/zdir.rb +36 -36
  14. data/lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb +1 -1
  15. data/lib/czmq-ffi-gen/czmq/ffi/zfile.rb +27 -19
  16. data/lib/czmq-ffi-gen/czmq/ffi/zframe.rb +22 -21
  17. data/lib/czmq-ffi-gen/czmq/ffi/zhash.rb +54 -54
  18. data/lib/czmq-ffi-gen/czmq/ffi/zhashx.rb +82 -80
  19. data/lib/czmq-ffi-gen/czmq/ffi/ziflist.rb +30 -0
  20. data/lib/czmq-ffi-gen/czmq/ffi/zlist.rb +30 -30
  21. data/lib/czmq-ffi-gen/czmq/ffi/zlistx.rb +44 -44
  22. data/lib/czmq-ffi-gen/czmq/ffi/zloop.rb +39 -39
  23. data/lib/czmq-ffi-gen/czmq/ffi/zmsg.rb +46 -46
  24. data/lib/czmq-ffi-gen/czmq/ffi/zpoller.rb +16 -16
  25. data/lib/czmq-ffi-gen/czmq/ffi/zproc.rb +237 -34
  26. data/lib/czmq-ffi-gen/czmq/ffi/zsock.rb +1201 -973
  27. data/lib/czmq-ffi-gen/czmq/ffi/zstr.rb +58 -19
  28. data/lib/czmq-ffi-gen/czmq/ffi/zsys.rb +836 -0
  29. data/lib/czmq-ffi-gen/czmq/ffi/ztimerset.rb +6 -6
  30. data/lib/czmq-ffi-gen/czmq/ffi/ztrie.rb +10 -10
  31. data/lib/czmq-ffi-gen/czmq/ffi/zuuid.rb +4 -4
  32. data/lib/czmq-ffi-gen/gem_version.rb +1 -1
  33. data/lib/czmq-ffi-gen/vendor.rb +9 -1
  34. data/vendor/local/bin/inproc_lat.exe +0 -0
  35. data/vendor/local/bin/inproc_thr.exe +0 -0
  36. data/vendor/local/bin/libczmq.dll +0 -0
  37. data/vendor/local/bin/libzmq.dll +0 -0
  38. data/vendor/local/bin/local_lat.exe +0 -0
  39. data/vendor/local/bin/local_thr.exe +0 -0
  40. data/vendor/local/bin/remote_lat.exe +0 -0
  41. data/vendor/local/bin/remote_thr.exe +0 -0
  42. data/vendor/local/bin/zmakecert.exe +0 -0
  43. data/vendor/local/include/czmq_library.h +18 -9
  44. data/vendor/local/include/czmq_prelude.h +104 -16
  45. data/vendor/local/include/zactor.h +25 -7
  46. data/vendor/local/include/zarmour.h +3 -3
  47. data/vendor/local/include/zcert.h +11 -6
  48. data/vendor/local/include/zcertstore.h +18 -9
  49. data/vendor/local/include/zchunk.h +18 -18
  50. data/vendor/local/include/zclock.h +6 -6
  51. data/vendor/local/include/zconfig.h +25 -16
  52. data/vendor/local/include/zdigest.h +4 -4
  53. data/vendor/local/include/zdir.h +36 -36
  54. data/vendor/local/include/zdir_patch.h +1 -1
  55. data/vendor/local/include/zfile.h +27 -19
  56. data/vendor/local/include/zframe.h +22 -21
  57. data/vendor/local/include/zgossip.h +5 -5
  58. data/vendor/local/include/zgossip_engine.inc +103 -22
  59. data/vendor/local/include/zgossip_msg.h +28 -30
  60. data/vendor/local/include/zhash.h +53 -53
  61. data/vendor/local/include/zhashx.h +75 -73
  62. data/vendor/local/include/ziflist.h +22 -1
  63. data/vendor/local/include/zlist.h +28 -28
  64. data/vendor/local/include/zlistx.h +41 -41
  65. data/vendor/local/include/zloop.h +36 -36
  66. data/vendor/local/include/zmsg.h +46 -46
  67. data/vendor/local/include/zpoller.h +16 -16
  68. data/vendor/local/include/zsock.h +414 -364
  69. data/vendor/local/include/zsock_option.inc +234 -1062
  70. data/vendor/local/include/zstr.h +44 -19
  71. data/vendor/local/include/zsys.h +63 -19
  72. data/vendor/local/include/zuuid.h +4 -4
  73. data/vendor/local/lib/libczmq.dll.a +0 -0
  74. data/vendor/local/lib/liblibzmq.dll.a +0 -0
  75. data/vendor/local/lib/pkgconfig/libczmq.pc +1 -1
  76. metadata +6 -3
@@ -132,7 +132,7 @@ module CZMQ
132
132
  result
133
133
  end
134
134
 
135
- # Set timer interval. Returns 0 if OK, -1 on failure.
135
+ # Set timer interval. Returns 0 if OK, -1 on failure.
136
136
  # This method is slow, canceling the timer and adding a new one yield better performance.
137
137
  #
138
138
  # @param timer_id [Integer, #to_int, #to_i]
@@ -148,7 +148,7 @@ module CZMQ
148
148
  end
149
149
 
150
150
  # Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure.
151
- # This method is slow, canceling the timer and adding a new one yield better performance.
151
+ # This method is slow, canceling the timer and adding a new one yield better performance.
152
152
  #
153
153
  # @param timer_id [Integer, #to_int, #to_i]
154
154
  # @return [Integer]
@@ -160,9 +160,9 @@ module CZMQ
160
160
  result
161
161
  end
162
162
 
163
- # Return the time until the next interval.
163
+ # Return the time until the next interval.
164
164
  # Should be used as timeout parameter for the zpoller wait method.
165
- # The timeout is in msec.
165
+ # The timeout is in msec.
166
166
  #
167
167
  # @return [Integer]
168
168
  def timeout()
@@ -173,8 +173,8 @@ module CZMQ
173
173
  end
174
174
 
175
175
  # Invoke callback function of all timers which their interval has elapsed.
176
- # Should be call after zpoller wait method.
177
- # Returns 0 if OK, -1 on failure.
176
+ # Should be call after zpoller wait method.
177
+ # Returns 0 if OK, -1 on failure.
178
178
  #
179
179
  # @return [Integer]
180
180
  def execute()
@@ -76,7 +76,7 @@ module CZMQ
76
76
  # Create a new callback of the following type:
77
77
  # Callback function for ztrie_node to destroy node data.
78
78
  # typedef void (ztrie_destroy_data_fn) (
79
- # void **data);
79
+ # void **data);
80
80
  #
81
81
  # @note WARNING: If your Ruby code doesn't retain a reference to the
82
82
  # FFI::Function object after passing it to a C function call,
@@ -107,9 +107,9 @@ module CZMQ
107
107
  result
108
108
  end
109
109
 
110
- # Inserts a new route into the tree and attaches the data. Returns -1
110
+ # Inserts a new route into the tree and attaches the data. Returns -1
111
111
  # if the route already exists, otherwise 0. This method takes ownership of
112
- # the provided data if a destroy_data_fn is provided.
112
+ # the provided data if a destroy_data_fn is provided.
113
113
  #
114
114
  # @param path [String, #to_s, nil]
115
115
  # @param data [::FFI::Pointer, #to_ptr]
@@ -123,8 +123,8 @@ module CZMQ
123
123
  end
124
124
 
125
125
  # Removes a route from the trie and destroys its data. Returns -1 if the
126
- # route does not exists, otherwise 0.
127
- # the start of the list call zlist_first (). Advances the cursor.
126
+ # route does not exists, otherwise 0.
127
+ # the start of the list call zlist_first (). Advances the cursor.
128
128
  #
129
129
  # @param path [String, #to_s, nil]
130
130
  # @return [Integer]
@@ -147,8 +147,8 @@ module CZMQ
147
147
  end
148
148
 
149
149
  # Returns the data of a matched route from last ztrie_matches. If the path
150
- # did not match, returns NULL. Do not delete the data as it's owned by
151
- # ztrie.
150
+ # did not match, returns NULL. Do not delete the data as it's owned by
151
+ # ztrie.
152
152
  #
153
153
  # @return [::FFI::Pointer]
154
154
  def hit_data()
@@ -168,9 +168,9 @@ module CZMQ
168
168
  result
169
169
  end
170
170
 
171
- # Returns the parameters of a matched route with named regexes from last
171
+ # Returns the parameters of a matched route with named regexes from last
172
172
  # ztrie_matches. If the path did not match or the route did not contain any
173
- # named regexes, returns NULL.
173
+ # named regexes, returns NULL.
174
174
  #
175
175
  # @return [Zhashx]
176
176
  def hit_parameters()
@@ -182,7 +182,7 @@ module CZMQ
182
182
  end
183
183
 
184
184
  # Returns the asterisk matched part of a route, if there has been no match
185
- # or no asterisk match, returns NULL.
185
+ # or no asterisk match, returns NULL.
186
186
  #
187
187
  # @return [String]
188
188
  def hit_asterisk_match()
@@ -110,7 +110,7 @@ module CZMQ
110
110
  end
111
111
 
112
112
  # Set UUID to new supplied string value skipping '-' and '{' '}'
113
- # optional delimiters. Return 0 if OK, else returns -1.
113
+ # optional delimiters. Return 0 if OK, else returns -1.
114
114
  #
115
115
  # @param source [String, #to_s, nil]
116
116
  # @return [Integer]
@@ -152,8 +152,8 @@ module CZMQ
152
152
  end
153
153
 
154
154
  # Return UUID in the canonical string format: 8-4-4-4-12, in lower
155
- # case. Caller does not modify or free returned value. See
156
- # http://en.wikipedia.org/wiki/Universally_unique_identifier
155
+ # case. Caller does not modify or free returned value. See
156
+ # http://en.wikipedia.org/wiki/Universally_unique_identifier
157
157
  #
158
158
  # @return [String]
159
159
  def str_canonical()
@@ -197,7 +197,7 @@ module CZMQ
197
197
  end
198
198
 
199
199
  # Make copy of UUID object; if uuid is null, or memory was exhausted,
200
- # returns null.
200
+ # returns null.
201
201
  #
202
202
  # @return [Zuuid]
203
203
  def dup()
@@ -1,5 +1,5 @@
1
1
  module CZMQ
2
2
  module FFI
3
- GEM_VERSION = "0.13.0"
3
+ GEM_VERSION = "0.14.1"
4
4
  end
5
5
  end
@@ -1,5 +1,13 @@
1
1
  base_dir = File.expand_path(File.join(__dir__, "..", ".."))
2
2
  vendor_bin_dir = File.join(base_dir, "vendor", "local", "bin")
3
3
  if File.exist?(vendor_bin_dir)
4
- ENV["PATH"] = [vendor_bin_dir, ENV["PATH"]].join(File::PATH_SEPARATOR)
4
+ # On Windows, RubyInstaller2 uses kernel32's SetDefaultDllDirectories
5
+ # and AddDllDirectory, which disables the lookup of DLLs in the PATH, see
6
+ # https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#dll-loading
7
+ begin
8
+ require 'ruby_installer'
9
+ RubyInstaller::Runtime.add_dll_directory vendor_bin_dir
10
+ rescue LoadError
11
+ ENV["PATH"] = [vendor_bin_dir, ENV["PATH"]].join(File::PATH_SEPARATOR)
12
+ end
5
13
  end
Binary file
Binary file
@@ -1,13 +1,13 @@
1
1
  /* =========================================================================
2
2
  czmq - generated layer of public API
3
3
 
4
- Copyright (c) the Contributors as noted in the AUTHORS file.
5
- This file is part of CZMQ, the high-level C binding for 0MQ:
6
- http://czmq.zeromq.org.
7
-
4
+ Copyright (c) the Contributors as noted in the AUTHORS file.
5
+ This file is part of CZMQ, the high-level C binding for 0MQ:
6
+ http://czmq.zeromq.org.
7
+
8
8
  This Source Code Form is subject to the terms of the Mozilla Public
9
9
  License, v. 2.0. If a copy of the MPL was not distributed with this
10
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
11
 
12
12
  ################################################################################
13
13
  # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
@@ -52,7 +52,7 @@
52
52
  # define CZMQ_PRIVATE
53
53
  #else
54
54
  # define CZMQ_EXPORT
55
- # if (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
55
+ # if (defined __GNUC__ && __GNUC__ >= 4 && !defined __CYGWIN__) || defined __INTEL_COMPILER
56
56
  # define CZMQ_PRIVATE __attribute__ ((visibility ("hidden")))
57
57
  # else
58
58
  # define CZMQ_PRIVATE
@@ -105,6 +105,8 @@ typedef struct _zsock_t zsock_t;
105
105
  #define ZSOCK_T_DEFINED
106
106
  typedef struct _zstr_t zstr_t;
107
107
  #define ZSTR_T_DEFINED
108
+ typedef struct _zsys_t zsys_t;
109
+ #define ZSYS_T_DEFINED
108
110
  typedef struct _zuuid_t zuuid_t;
109
111
  #define ZUUID_T_DEFINED
110
112
  typedef struct _zauth_t zauth_t;
@@ -119,10 +121,10 @@ typedef struct _zproxy_t zproxy_t;
119
121
  #define ZPROXY_T_DEFINED
120
122
  typedef struct _zrex_t zrex_t;
121
123
  #define ZREX_T_DEFINED
122
- typedef struct _zsys_t zsys_t;
123
- #define ZSYS_T_DEFINED
124
124
  // Draft classes are by default not built in stable releases
125
125
  #ifdef CZMQ_BUILD_DRAFT_API
126
+ typedef struct _zargs_t zargs_t;
127
+ #define ZARGS_T_DEFINED
126
128
  typedef struct _zproc_t zproc_t;
127
129
  #define ZPROC_T_DEFINED
128
130
  typedef struct _ztimerset_t ztimerset_t;
@@ -155,6 +157,7 @@ typedef struct _ztrie_t ztrie_t;
155
157
  #include "zpoller.h"
156
158
  #include "zsock.h"
157
159
  #include "zstr.h"
160
+ #include "zsys.h"
158
161
  #include "zuuid.h"
159
162
  #include "zauth.h"
160
163
  #include "zbeacon.h"
@@ -162,13 +165,19 @@ typedef struct _ztrie_t ztrie_t;
162
165
  #include "zmonitor.h"
163
166
  #include "zproxy.h"
164
167
  #include "zrex.h"
165
- #include "zsys.h"
166
168
  #ifdef CZMQ_BUILD_DRAFT_API
169
+ #include "zargs.h"
167
170
  #include "zproc.h"
168
171
  #include "ztimerset.h"
169
172
  #include "ztrie.h"
170
173
  #endif // CZMQ_BUILD_DRAFT_API
171
174
 
175
+ #ifdef CZMQ_BUILD_DRAFT_API
176
+ // Self test for private classes
177
+ CZMQ_EXPORT void
178
+ czmq_private_selftest (bool verbose);
179
+ #endif // CZMQ_BUILD_DRAFT_API
180
+
172
181
  #endif
173
182
  /*
174
183
  ################################################################################
@@ -17,7 +17,8 @@
17
17
  //- Establish the compiler and computer system ------------------------------
18
18
  /*
19
19
  * Defines zero or more of these symbols, for use in any non-portable
20
- * code:
20
+ * code (for pre-defined values see e.g. build-system headers as well
21
+ * as output of GNU C preprocessor via `cpp -dM < /dev/null`):
21
22
  *
22
23
  * __WINDOWS__ Microsoft C/C++ with Windows calls
23
24
  * __MSDOS__ System is MS-DOS (set if __WINDOWS__ set)
@@ -164,7 +165,7 @@
164
165
  #elif (defined (Mips))
165
166
  # define __UTYPE_MIPS
166
167
  # define __UNIX__
167
- #elif (defined (FreeBSD) || defined (__FreeBSD__))
168
+ #elif (defined (FreeBSD) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__))
168
169
  # define __UTYPE_FREEBSD
169
170
  # define __UNIX__
170
171
  #elif (defined (NetBSD) || defined (__NetBSD__))
@@ -193,10 +194,12 @@
193
194
  #elif (defined (sinix))
194
195
  # define __UTYPE_SINIX
195
196
  # define __UNIX__
196
- #elif (defined (SOLARIS) || defined (__SVR4)) || defined (SVR4)
197
+ #elif (defined (SOLARIS) || defined (__SVR4) || defined (SVR4) || defined (__SVR4__) || defined (__svr4) || defined (svr4) || defined (__svr4__))
198
+ // Note: this rule and below should match legacy SunOS and Solaris
199
+ // on builds without the GNU toolchain; with one you get __UTYPE_GNU
197
200
  # define __UTYPE_SUNSOLARIS
198
201
  # define __UNIX__
199
- #elif (defined (SUNOS) || defined (SUN) || defined (sun))
202
+ #elif (defined (SUNOS) || defined (SUN) || defined (sun) || defined (__sun) || defined (__sun__))
200
203
  # define __UTYPE_SUNOS
201
204
  # define __UNIX__
202
205
  #elif (defined (__USLC__) || defined (UnixWare))
@@ -419,21 +422,89 @@ typedef struct {
419
422
 
420
423
  #define streq(s1,s2) (!strcmp ((s1), (s2)))
421
424
  #define strneq(s1,s2) (strcmp ((s1), (s2)))
422
-
423
- // Provide random number from 0..(num-1)
424
- // Note that (at least in Solaris) while rand() returns an int limited by
425
- // RAND_MAX, random() returns a 32-bit value all filled with random bits.
426
- #if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \
425
+ #define freen(x) do {free(x); x = NULL;} while(0)
426
+
427
+ // randof(num) : Provide random number from 0..(num-1)
428
+ // ASSUMES that "num" itself is at most an int (bit size no more than float
429
+ // on the host platform), and non-negative; may be a "function()" token.
430
+ // For practical reasons, "num" should be under 50M or so.
431
+ // The math libraries on different platforms and capabilities in HW are a
432
+ // nightmare. Seems we have to drown the code in casts to have reasonable
433
+ // results... Also note that the 32-bit float has a hard time representing
434
+ // values close to UINT32_MAX that we had before, so now limit to UINT16_MAX.
435
+ // Platforms where RAND_MAX is comparable to even signed INT32_MAX were
436
+ // rigged with problems here: even if the code used double-precision, the
437
+ // corner-case factors (divident close to INT32_MAX and close to divisor)
438
+ // were too close to 1.0, so the final product was "num" rather than "num-1".
439
+ // Finally note that on some platforms RAND_MAX can be smallish, like 32767,
440
+ // so we should use it if small enough.
441
+
442
+ // Precision for our calculations impacts the MAX values we can use below
443
+ // Still, say UINT64_MAX is overkill. But smaller MAXes can yield better
444
+ // distribution of values with e.g. double.
445
+ #if !defined (ZSYS_RANDOF_FLT)
446
+ # define ZSYS_RANDOF_FLT float
447
+ #endif // ZSYS_RANDOF_FLT is defined by caller... trust them or explode later
448
+
449
+ // Implementations vary... Note that many will get __UTYPE_GNU nowadays.
450
+ #if !defined (ZSYS_RANDOF_FUNC)
451
+ # if defined (ZSYS_RANDOF_FUNC_BITS)
452
+ # undef ZSYS_RANDOF_FUNC_BITS
453
+ # endif
454
+ # if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \
427
455
  || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS)) || (defined (__UTYPE_SOLARIS))
428
- # define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0))
429
- #else
430
- # if defined(RAND_MAX)
431
- # define randof(num) (int) ((float) (num) * (random () % RAND_MAX) / (RAND_MAX + 1.0))
456
+ # define ZSYS_RANDOF_FUNC rand
457
+ # define ZSYS_RANDOF_FUNC_BITS 15
432
458
  # else
433
- # define randof(num) (int) ((float) (num) * (uint32_t)random () / (UINT32_MAX + 1.0))
459
+ # define ZSYS_RANDOF_FUNC random
460
+ # define ZSYS_RANDOF_FUNC_BITS 32
461
+ # endif
462
+ #endif // ZSYS_RANDOF_FUNC is defined by caller... trust them or explode later
463
+
464
+ // Limits below were experimented for 32-bit floats on x86 with test_randof
465
+ // Due to discrete rounding, greater values caused collisions with the
466
+ // fraction s_randof_factor() defined below returning 1.0.
467
+ #if !defined (ZSYS_RANDOF_MAX)
468
+ # if (ZSYS_RANDOF_FUNC_BITS >= 26)
469
+ // Assume that random() is at least 32-bit as it is on most platforms
470
+ # define ZSYS_RANDOF_MAX (UINT32_MAX>>6)
471
+ # else
472
+ # if defined (RAND_MAX)
473
+ # if (RAND_MAX > (UINT32_MAX>>6))
474
+ # define ZSYS_RANDOF_MAX (UINT32_MAX>>6)
475
+ # else // RAND_MAX is small enough to not overflow our calculations
476
+ # define ZSYS_RANDOF_MAX RAND_MAX
477
+ # endif
478
+ # else // No RAND_MAX - use a smaller safer limit, but with values too discrete
479
+ # define ZSYS_RANDOF_MAX INT16_MAX
480
+ # endif
481
+ # endif // not random()
482
+ #endif // ZSYS_RANDOF_MAX is defined by caller... trust them or explode later
483
+
484
+ #define s_randof_factor() (ZSYS_RANDOF_FLT)( (ZSYS_RANDOF_FLT)(ZSYS_RANDOF_FUNC() % (ZSYS_RANDOF_MAX - 1)) / ( (ZSYS_RANDOF_FLT)(ZSYS_RANDOF_MAX) ) )
485
+
486
+ // Supplement the limited spectrum of ZSYS_RANDOF_MAX by stacking more random()s
487
+ // Note this can still be too little for very large "num" > ZSYS_RANDOF_MAX
488
+ // but we'd need a real randof() function to handle stacking in that case.
489
+ // Fuzziness added below (division by slightly more than a whole number) solves
490
+ // this wonderfully even for "num" ranges twice as big as the ZSYS_RANDOF_MAX.
491
+ #if (ZSYS_RANDOF_MAX > UINT16_MAX)
492
+ # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * s_randof_factor() / ( 1.0 + s_randof_factor() / 100.0 ) )
493
+ #else // boost dispersion
494
+ # if (ZSYS_RANDOF_MAX > INT16_MAX)
495
+ # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() ) / ( 2.0 + s_randof_factor() / 2.0 ) )
496
+ # else
497
+ # if (ZSYS_RANDOF_MAX > UINT8_MAX)
498
+ # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() ) / ( 4.0 + s_randof_factor() * 10.0 ) )
499
+ # else
500
+ # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() ) / ( 6.0 + s_randof_factor() * 100.0 ) )
501
+ # endif
434
502
  # endif
435
503
  #endif
436
504
 
505
+ // That's it about the randof() macro definition...
506
+
507
+
437
508
  // Windows MSVS doesn't have stdbool
438
509
  #if (defined (_MSC_VER))
439
510
  # if (!defined (__cplusplus) && (!defined (true)))
@@ -496,6 +567,18 @@ typedef intptr_t ssize_t;
496
567
  # if (!defined (PRId64))
497
568
  # define PRId64 "I64d"
498
569
  # endif
570
+ # if (!defined (PRIi8))
571
+ # define PRIi8 "i"
572
+ # endif
573
+ # if (!defined (PRIi16))
574
+ # define PRIi16 "i"
575
+ # endif
576
+ # if (!defined (PRIi32))
577
+ # define PRIi32 "i"
578
+ # endif
579
+ # if (!defined (PRIi64))
580
+ # define PRIi64 "I64i"
581
+ # endif
499
582
  # if (!defined (PRIu8))
500
583
  # define PRIu8 "u"
501
584
  # endif
@@ -512,7 +595,7 @@ typedef intptr_t ssize_t;
512
595
  // MSVC does not support C99's va_copy so we use a regular assignment
513
596
  # define va_copy(dest,src) (dest) = (src)
514
597
  # endif
515
- #elif (defined (__UTYPE_OSX))
598
+ #elif (defined (__UTYPE_OSX) || defined (__OpenBSD__))
516
599
  typedef unsigned long ulong;
517
600
  typedef unsigned int uint;
518
601
  // This fixes header-order dependence problem with some Linux versions
@@ -571,7 +654,9 @@ typedef int SOCKET;
571
654
  # define closesocket close
572
655
  # define INVALID_SOCKET -1
573
656
  # define SOCKET_ERROR -1
574
- # define O_BINARY 0
657
+ # if !defined O_BINARY
658
+ # define O_BINARY 0
659
+ # endif
575
660
  #endif
576
661
 
577
662
  //- Include non-portable header files based on platform.h -------------------
@@ -580,6 +665,9 @@ typedef int SOCKET;
580
665
  # include <linux/wireless.h>
581
666
  // This would normally come from net/if.h
582
667
  unsigned int if_nametoindex (const char *ifname);
668
+ char *if_indextoname (unsigned int ifindex, char *ifname);
669
+ // 32 on Linux, 256 on Windows, pick largest to avoid overflows
670
+ # define IF_NAMESIZE 256
583
671
  #else
584
672
  # if defined (HAVE_NET_IF_H)
585
673
  # include <net/if.h>
@@ -1,5 +1,5 @@
1
1
  /* =========================================================================
2
- zactor - actor
2
+ zactor - actor
3
3
 
4
4
  Copyright (c) the Contributors as noted in the AUTHORS file.
5
5
  This file is part of CZMQ, the high-level C binding for 0MQ:
@@ -23,6 +23,8 @@ extern "C" {
23
23
  // @interface
24
24
  // This is a stable class, and may not change except for emergencies. It
25
25
  // is provided in stable builds.
26
+ // This class has draft methods, which may change over time. They are not
27
+ // in stable releases, by default. Use --enable-drafts to enable.
26
28
  // Actors get a pipe and arguments from caller
27
29
  typedef void (zactor_fn) (
28
30
  zsock_t *pipe, void *args);
@@ -36,13 +38,13 @@ CZMQ_EXPORT void
36
38
  zactor_destroy (zactor_t **self_p);
37
39
 
38
40
  // Send a zmsg message to the actor, take ownership of the message
39
- // and destroy when it has been sent.
41
+ // and destroy when it has been sent.
40
42
  CZMQ_EXPORT int
41
43
  zactor_send (zactor_t *self, zmsg_t **msg_p);
42
44
 
43
- // Receive a zmsg message from the actor. Returns NULL if the actor
45
+ // Receive a zmsg message from the actor. Returns NULL if the actor
44
46
  // was interrupted before the message could be received, or if there
45
- // was a timeout on the actor.
47
+ // was a timeout on the actor.
46
48
  // Caller owns return value and must destroy it when done.
47
49
  CZMQ_EXPORT zmsg_t *
48
50
  zactor_recv (zactor_t *self);
@@ -52,13 +54,13 @@ CZMQ_EXPORT bool
52
54
  zactor_is (void *self);
53
55
 
54
56
  // Probe the supplied reference. If it looks like a zactor_t instance,
55
- // return the underlying libzmq actor handle; else if it looks like
56
- // a libzmq actor handle, return the supplied value.
57
+ // return the underlying libzmq actor handle; else if it looks like
58
+ // a libzmq actor handle, return the supplied value.
57
59
  CZMQ_EXPORT void *
58
60
  zactor_resolve (void *self);
59
61
 
60
62
  // Return the actor's zsock handle. Use this when you absolutely need
61
- // to work with the zsock instance rather than the actor.
63
+ // to work with the zsock instance rather than the actor.
62
64
  CZMQ_EXPORT zsock_t *
63
65
  zactor_sock (zactor_t *self);
64
66
 
@@ -66,6 +68,22 @@ CZMQ_EXPORT zsock_t *
66
68
  CZMQ_EXPORT void
67
69
  zactor_test (bool verbose);
68
70
 
71
+ #ifdef CZMQ_BUILD_DRAFT_API
72
+ // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame.
73
+ //
74
+ // An example - to send $KTHXBAI string
75
+ //
76
+ // if (zstr_send (self->pipe, "$KTHXBAI") == 0)
77
+ // zsock_wait (self->pipe);
78
+ typedef void (zactor_destructor_fn) (
79
+ zactor_t *self);
80
+
81
+ // *** Draft method, for development use, may change without warning ***
82
+ // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM.
83
+ CZMQ_EXPORT void
84
+ zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor);
85
+
86
+ #endif // CZMQ_BUILD_DRAFT_API
69
87
  // @end
70
88
 
71
89