Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code cleanups

  • Loading branch information...
commit c84f2e6484e2363502a26ea4bb7f0153c97a3226 1 parent 99cd20f
@hintjens authored
View
2  include/czmq_prelude.h
@@ -366,7 +366,7 @@
//- Data types --------------------------------------------------------------
-typedef int Bool; // Boolean TRUE/FALSE value
+typedef bool Bool; // Boolean TRUE/FALSE value
typedef unsigned char byte; // Single unsigned byte = 8 bits
typedef unsigned short dbyte; // Double byte = 16 bits
typedef unsigned int qbyte; // Quad byte = 32 bits
View
2  include/zclock.h
@@ -47,7 +47,7 @@ CZMQ_EXPORT void
// Self test of this class
int
- zclock_test (Bool verbose);
+ zclock_test (bool verbose);
// @end
#ifdef __cplusplus
View
2  include/zctx.h
@@ -74,7 +74,7 @@ CZMQ_EXPORT void *
// Self test of this class
int
- zctx_test (Bool verbose);
+ zctx_test (bool verbose);
// Global signal indicator, TRUE when user presses Ctrl-C or the process
// gets a SIGTERM signal.
View
2  include/zfile.h
@@ -50,7 +50,7 @@ CZMQ_EXPORT ssize_t
// Self test of this class
int
- zfile_test (Bool verbose);
+ zfile_test (bool verbose);
// @end
#ifdef __cplusplus
View
6 include/zframe.h
@@ -92,7 +92,7 @@ CZMQ_EXPORT char *
zframe_strdup (zframe_t *self);
// Return TRUE if frame body is equal to string, excluding terminator
-CZMQ_EXPORT Bool
+CZMQ_EXPORT bool
zframe_streq (zframe_t *self, const char *string);
// Return frame zero copy indicator (1 or 0)
@@ -105,7 +105,7 @@ CZMQ_EXPORT int
// Return TRUE if two frames have identical size and data
// If either frame is NULL, equality is always false.
-CZMQ_EXPORT Bool
+CZMQ_EXPORT bool
zframe_eq (zframe_t *self, zframe_t *other);
// Print contents of frame to stderr
@@ -118,7 +118,7 @@ CZMQ_EXPORT void
// Self test of this class
int
- zframe_test (Bool verbose);
+ zframe_test (bool verbose);
// @end
#ifdef __cplusplus
View
4 include/zloop.h
@@ -73,7 +73,7 @@ CZMQ_EXPORT int
// Set verbose tracing of reactor on/off
CZMQ_EXPORT void
- zloop_set_verbose (zloop_t *self, Bool verbose);
+ zloop_set_verbose (zloop_t *self, bool verbose);
// Start the reactor. Takes control of the thread and returns when the 0MQ
// context is terminated or the process is interrupted, or any event handler
@@ -84,7 +84,7 @@ CZMQ_EXPORT int
// Self test of this class
int
- zloop_test (Bool verbose);
+ zloop_test (bool verbose);
// @end
View
2  include/zmsg.h
@@ -149,7 +149,7 @@ CZMQ_EXPORT void
// Self test of this class
int
- zmsg_test (Bool verbose);
+ zmsg_test (bool verbose);
// @end
#ifdef __cplusplus
View
4 include/zsocket.h
@@ -69,7 +69,7 @@ CZMQ_EXPORT int
// Poll for input events on the socket. Returns TRUE if there is input
// ready on the socket, else FALSE.
-CZMQ_EXPORT Bool
+CZMQ_EXPORT bool
zsocket_poll (void *socket, int msecs);
// Returns socket type as printable constant string
@@ -78,7 +78,7 @@ CZMQ_EXPORT char *
// Self test of this class
int
- zsocket_test (Bool verbose);
+ zsocket_test (bool verbose);
// @end
#ifdef __cplusplus
View
2  include/zsockopt.h
@@ -142,7 +142,7 @@ void zsocket_set_hwm (void *zocket, int hwm);
#endif
// Self test of this class
-int zsockopt_test (Bool verbose);
+int zsockopt_test (bool verbose);
// @end
// Deprecated function names
View
2  include/zstr.h
@@ -58,7 +58,7 @@ CZMQ_EXPORT int
// Self test of this class
int
- zstr_test (Bool verbose);
+ zstr_test (bool verbose);
// @end
#ifdef __cplusplus
View
2  include/zthread.h
@@ -53,7 +53,7 @@ CZMQ_EXPORT void *
// Self test of this class
int
- zthread_test (Bool verbose);
+ zthread_test (bool verbose);
// @end
#ifdef __cplusplus
View
4 sockopts.gsl
@@ -83,7 +83,7 @@ $(string.trim(.):)
.endfor
// Self test of this class
-int zsockopt_test (Bool verbose);
+int zsockopt_test (bool verbose);
// @end
.for version
@@ -260,7 +260,7 @@ $(string.trim(.):)
// Selftest
int
-zsockopt_test (Bool verbose)
+zsockopt_test (bool verbose)
{
printf (" * zsockopt: ");
View
2  src/Makefile.am
@@ -14,6 +14,7 @@ include_HEADERS = \
../include/zlist.h \
../include/zloop.h \
../include/zmsg.h \
+ ../include/zmutex.h \
../include/zsocket.h \
../include/zsockopt.h \
../include/zstr.h \
@@ -28,6 +29,7 @@ libczmq_la_SOURCES = \
zlist.c \
zloop.c \
zmsg.c \
+ zmutex.c \
zsocket.c \
zsockopt.c \
zstr.c \
View
3  src/czmq_selftest.c
@@ -30,7 +30,7 @@
int main (int argc, char *argv [])
{
- Bool verbose;
+ bool verbose;
if (argc == 2 && streq (argv [1], "-v"))
verbose = TRUE;
else
@@ -46,6 +46,7 @@ int main (int argc, char *argv [])
zlist_test (verbose);
zloop_test (verbose);
zmsg_test (verbose);
+ zmutex_test (verbose);
zsocket_test (verbose);
zsockopt_test (verbose);
zstr_test (verbose);
View
4 src/zclock.c
@@ -5,7 +5,7 @@
Copyright (c) 1991-2012 iMatix Corporation <www.imatix.com>
Copyright other contributors as noted in the AUTHORS file.
- This file is part of czmq, the C binding for 0MQ: http://czmq.zeromq.org.
+ This file is part of CZMQ, the C binding for 0MQ: http://czmq.zeromq.org.
This is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
@@ -135,7 +135,7 @@ zclock_log (const char *format, ...)
// Self test of this class
int
-zclock_test (Bool verbose)
+zclock_test (bool verbose)
{
printf (" * zclock: ");
View
4 src/zctx.c
@@ -61,7 +61,7 @@
struct _zctx_t {
void *context; // Our 0MQ context
zlist_t *sockets; // Sockets held by this thread
- Bool main; // TRUE if we're the main thread
+ bool main; // TRUE if we're the main thread
int iothreads; // Number of IO threads, default 1
int linger; // Linger timeout, default 0
int hwm; // HWM, default 1
@@ -263,7 +263,7 @@ zctx__socket_destroy (zctx_t *self, void *zocket)
// Selftest
int
-zctx_test (Bool verbose)
+zctx_test (bool verbose)
{
printf (" * zctx: ");
View
4 src/zfile.c
@@ -5,7 +5,7 @@
Copyright (c) 1991-2012 iMatix Corporation <www.imatix.com>
Copyright other contributors as noted in the AUTHORS file.
- This file is part of czmq, the high-level C binding for 0MQ:
+ This file is part of CZMQ, the high-level C binding for 0MQ:
http://czmq.zeromq.org.
This is free software; you can redistribute it and/or modify it under
@@ -122,7 +122,7 @@ zfile_size (const char *filename)
// Selftest
int
-zfile_test (Bool verbose)
+zfile_test (bool verbose)
{
printf (" * zfile: ");
View
6 src/zframe.c
@@ -274,7 +274,7 @@ zframe_strdup (zframe_t *self)
// --------------------------------------------------------------------------
// Return TRUE if frame body is equal to string, excluding terminator
-Bool
+bool
zframe_streq (zframe_t *self, const char *string)
{
assert (self);
@@ -310,7 +310,7 @@ zframe_zero_copy (zframe_t *self)
// --------------------------------------------------------------------------
// Return TRUE if two frames have identical size and data
-Bool
+bool
zframe_eq (zframe_t *self, zframe_t *other)
{
if (!self || !other)
@@ -390,7 +390,7 @@ s_test_free_cb (void *data, void *arg)
}
int
-zframe_test (Bool verbose)
+zframe_test (bool verbose)
{
printf (" * zframe: ");
int rc;
View
4 src/zhash.c
@@ -148,7 +148,7 @@ s_item_insert (zhash_t *self, const char *key, void *value)
// Destroy item in hash table, item must exist in table
static void
-s_item_destroy (zhash_t *self, item_t *item, Bool hard)
+s_item_destroy (zhash_t *self, item_t *item, bool hard)
{
// Find previous item since it's a singly-linked list
item_t *cur_item = self->items [item->index];
@@ -521,7 +521,7 @@ zhash_test (int verbose)
// Check that the queue is robust against random usage
struct {
char name [100];
- Bool exists;
+ bool exists;
} testset [200];
memset (testset, 0, sizeof (testset));
int testmax = 200, testnbr, iteration;
View
17 src/zloop.c
@@ -47,8 +47,8 @@ struct _zloop_t {
size_t poll_size; // Size of poll set
zmq_pollitem_t *pollset; // zmq_poll set
s_poller_t *pollact; // Pollers for this poll set
- Bool dirty; // True if pollset needs rebuilding
- Bool verbose; // True if verbose tracing wanted
+ bool dirty; // True if pollset needs rebuilding
+ bool verbose; // True if verbose tracing wanted
zlist_t *zombies; // List of timers to kill
};
@@ -57,7 +57,7 @@ struct _s_poller_t {
zmq_pollitem_t item;
zloop_fn *handler;
void *arg;
- Bool ignore_errors;
+ bool ignore_errors;
int errors; // If too many errors, kill poller
};
@@ -74,7 +74,7 @@ s_poller_new (zmq_pollitem_t *item, zloop_fn handler, void *arg)
{
s_poller_t *poller = (s_poller_t *) zmalloc (sizeof (s_poller_t));
if (poller) {
- poller->ignore_errors = (item->events & ZMQ_IGNERR);
+ poller->ignore_errors = (item->events & ZMQ_IGNERR);
poller->item = *item;
poller->handler = handler;
poller->arg = arg;
@@ -320,7 +320,7 @@ zloop_timer_end (zloop_t *self, void *arg)
// --------------------------------------------------------------------------
// Set verbose tracing of reactor on/off
void
-zloop_set_verbose (zloop_t *self, Bool verbose)
+zloop_set_verbose (zloop_t *self, bool verbose)
{
self->verbose = verbose;
}
@@ -385,8 +385,9 @@ zloop_start (zloop_t *self)
for (item_nbr = 0; item_nbr < self->poll_size; item_nbr++) {
s_poller_t *poller = &self->pollact [item_nbr];
assert (self->pollset [item_nbr].socket == poller->item.socket);
- if ((self->pollset [item_nbr].revents & ZMQ_POLLERR) &&
- !poller->ignore_errors) {
+
+ if ((self->pollset [item_nbr].revents & ZMQ_POLLERR)
+ && !poller->ignore_errors) {
if (self->verbose)
zclock_log ("I: zloop: can't poll %s socket (%p, %d): %s",
poller->item.socket?
@@ -452,7 +453,7 @@ s_socket_event (zloop_t *loop, zmq_pollitem_t *item, void *arg)
}
int
-zloop_test (Bool verbose)
+zloop_test (bool verbose)
{
printf (" * zloop: ");
int rc = 0;
View
2  src/zmsg.c
@@ -649,7 +649,7 @@ zmsg_dump (zmsg_t *self)
// Selftest
int
-zmsg_test (Bool verbose)
+zmsg_test (bool verbose)
{
printf (" * zmsg: ");
View
39 src/zsocket.c
@@ -5,7 +5,7 @@
Copyright (c) 1991-2012 iMatix Corporation <www.imatix.com>
Copyright other contributors as noted in the AUTHORS file.
- This file is part of czmq, the high-level C binding for 0MQ:
+ This file is part of CZMQ, the high-level C binding for 0MQ:
http://czmq.zeromq.org.
This is free software; you can redistribute it and/or modify it under
@@ -44,8 +44,8 @@
void *
zsocket_new (zctx_t *ctx, int type)
{
- void *zocket = zctx__socket_new (ctx, type);
- return zocket;
+ void *self = zctx__socket_new (ctx, type);
+ return self;
}
@@ -54,10 +54,10 @@ zsocket_new (zctx_t *ctx, int type)
// zsocket_new method. If socket is null, does nothing.
void
-zsocket_destroy (zctx_t *ctx, void *zocket)
+zsocket_destroy (zctx_t *ctx, void *self)
{
- if (zocket)
- zctx__socket_destroy (ctx, zocket);
+ if (self)
+ zctx__socket_destroy (ctx, self);
}
@@ -68,7 +68,7 @@ zsocket_destroy (zctx_t *ctx, void *zocket)
// port number if successful.
int
-zsocket_bind (void *zocket, const char *format, ...)
+zsocket_bind (void *self, const char *format, ...)
{
// Ephemeral port needs 4 additional characters
char endpoint [256 + 4];
@@ -85,16 +85,15 @@ zsocket_bind (void *zocket, const char *format, ...)
int port;
for (port = ZSOCKET_DYNFROM; port < ZSOCKET_DYNTO; port++) {
sprintf (endpoint + endpoint_size - 1, "%d", port);
- if (zmq_bind (zocket, endpoint) == 0) {
+ if (zmq_bind (self, endpoint) == 0) {
rc = port;
break;
}
}
}
else {
- rc = zmq_bind (zocket, endpoint);
-
// Return actual port used for binding
+ rc = zmq_bind (self, endpoint);
if (rc == 0)
rc = atoi (strrchr (endpoint, ':') + 1);
else
@@ -109,14 +108,14 @@ zsocket_bind (void *zocket, const char *format, ...)
// Returns 0 if the endpoint is valid, -1 if the connect failed.
int
-zsocket_connect (void *zocket, const char *format, ...)
+zsocket_connect (void *self, const char *format, ...)
{
char endpoint [256];
va_list argptr;
va_start (argptr, format);
vsnprintf (endpoint, 256, format, argptr);
va_end (argptr);
- return zmq_connect (zocket, endpoint);
+ return zmq_connect (self, endpoint);
}
// --------------------------------------------------------------------------
@@ -124,7 +123,7 @@ zsocket_connect (void *zocket, const char *format, ...)
// Returns 0 if disconnection is complete -1 if the disconnection failed.
int
-zsocket_disconnect (void *zocket, const char *format, ...)
+zsocket_disconnect (void *self, const char *format, ...)
{
#if (ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,2,0))
char endpoint [256];
@@ -132,7 +131,7 @@ zsocket_disconnect (void *zocket, const char *format, ...)
va_start (argptr, format);
vsnprintf (endpoint, 256, format, argptr);
va_end (argptr);
- return zmq_disconnect (zocket, endpoint);
+ return zmq_disconnect (self, endpoint);
#else
return -1;
#endif
@@ -142,10 +141,10 @@ zsocket_disconnect (void *zocket, const char *format, ...)
// Poll for input events on the socket. Returns TRUE if there is input
// ready on the socket, else FALSE.
-Bool
-zsocket_poll (void *zocket, int msecs)
+bool
+zsocket_poll (void *self, int msecs)
{
- zmq_pollitem_t items [] = { { zocket, 0, ZMQ_POLLIN, 0 } };
+ zmq_pollitem_t items [] = { { self, 0, ZMQ_POLLIN, 0 } };
int rc = zmq_poll (items, 1, msecs);
return rc != -1 && (items [0].revents & ZMQ_POLLIN) != 0;
}
@@ -155,14 +154,14 @@ zsocket_poll (void *zocket, int msecs)
// Returns socket type as printable constant string
char *
-zsocket_type_str (void *zocket)
+zsocket_type_str (void *self)
{
char *type_name [] = {
"PAIR", "PUB", "SUB", "REQ", "REP",
"DEALER", "ROUTER", "PULL", "PUSH",
"XPUB", "XSUB"
};
- int type = zsockopt_type (zocket);
+ int type = zsockopt_type (self);
if (type < 0 || type > ZMQ_XSUB)
return "UNKNOWN";
else
@@ -174,7 +173,7 @@ zsocket_type_str (void *zocket)
// Selftest
int
-zsocket_test (Bool verbose)
+zsocket_test (bool verbose)
{
printf (" * zsocket: ");
View
2  src/zsockopt.c
@@ -1253,7 +1253,7 @@ zsocket_set_hwm (void *zocket, int hwm)
// Selftest
int
-zsockopt_test (Bool verbose)
+zsockopt_test (bool verbose)
{
printf (" * zsockopt: ");
View
4 src/zstr.c
@@ -118,7 +118,7 @@ zstr_sendm (void *zocket, const char *string)
}
static int
-s_zstr_sendf_impl (void *zocket, Bool more, const char *format, va_list argptr)
+s_zstr_sendf_impl (void *zocket, bool more, const char *format, va_list argptr)
{
assert (zocket);
@@ -178,7 +178,7 @@ zstr_sendfm (void *zocket, const char *format, ...)
// Selftest
int
-zstr_test (Bool verbose)
+zstr_test (bool verbose)
{
printf (" * zstr: ");
View
2  src/zthread.c
@@ -237,7 +237,7 @@ s_test_attached (void *args, zctx_t *ctx, void *pipe)
// @end
int
-zthread_test (Bool verbose)
+zthread_test (bool verbose)
{
printf (" * zthread: ");
Please sign in to comment.
Something went wrong with that request. Please try again.