]> granicus.if.org Git - libevent/commitdiff
Treat the bitwise OR of two enum values as an int.
authorNick Mathewson <nickm@torproject.org>
Wed, 21 Oct 2009 18:48:22 +0000 (18:48 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 21 Oct 2009 18:48:22 +0000 (18:48 +0000)
This makes our interfaces usable from C++, which doesn't believe
you can say    "bufferevent_socket_nase(base, -1,
BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS)" but which instead
would demand "static_cast<bufferevent_options>(BEV_OPT_CLOSE_ON_FREE|
BEV_OPT_DEFER_CALLBACKS))" for the last argument.

Diagnosis and patch from Chris Davis.

svn:r1456

ChangeLog
bufferevent_filter.c
bufferevent_openssl.c
bufferevent_pair.c
bufferevent_sock.c
event.c
include/event2/bufferevent.h
include/event2/bufferevent_ssl.h
include/event2/event.h

index 944818e7e5f48987b354c85baac53f6f04be1b42..6ad1a1d66eed2e425f876822ddc86a85b327d91d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@ Changes in 2.0.3-alpha:
  o Make the event_base_loop() family of functions respect thread-safety better.  This should clear up a few hard-to-debug race conditions.
  o Fix a bug when using a specialized memory allocator on win32.
  o Have the win32 select() backend label TCP-socket-connected events as EV_WRITE, not EV_READ.  This should bring it in line with the other backends, and improve portability.  Patch from Christopher Davis.
+ o Stop using enums as arguments or return values when what we mean is a bitfield of enum values.  C++ doesn't believe that you can OR two enum values together and get another enum, and C++ takes its typing seriously.  Patch from Christopher Davis.
 
 
 Changes in 2.0.2-alpha:
index 9e5bb34572b0d4854eb573f49c8746e390023729..33966d059041cf4976b78e14319219d98a635d69 100644 (file)
@@ -165,12 +165,12 @@ struct bufferevent *
 bufferevent_filter_new(struct bufferevent *underlying,
                       bufferevent_filter_cb input_filter,
                       bufferevent_filter_cb output_filter,
-                      enum bufferevent_options options,
+                      int options,
                       void (*free_context)(void *),
                       void *ctx)
 {
        struct bufferevent_filtered *bufev_f;
-       enum bufferevent_options tmp_options = options & ~BEV_OPT_THREADSAFE;
+       int tmp_options = options & ~BEV_OPT_THREADSAFE;
 
        if (!input_filter)
                input_filter = be_null_filter;
index dd6f973add8295377af232a31d4e872aa8f685fa..6a32a41afa86ca99ff13c5ea0b89e96670a29ea3 100644 (file)
@@ -1047,11 +1047,11 @@ bufferevent_openssl_new_impl(struct event_base *base,
     evutil_socket_t fd,
     SSL *ssl,
     enum bufferevent_ssl_state state,
-    enum bufferevent_options options)
+    int options)
 {
        struct bufferevent_openssl *bev_ssl = NULL;
        struct bufferevent_private *bev_p = NULL;
-       enum bufferevent_options tmp_options = options & ~BEV_OPT_THREADSAFE;
+       int tmp_options = options & ~BEV_OPT_THREADSAFE;
 
        if (underlying != NULL && fd >= 0)
                return NULL; /* Only one can be set. */
@@ -1123,7 +1123,7 @@ bufferevent_openssl_filter_new(struct event_base *base,
     struct bufferevent *underlying,
     SSL *ssl,
     enum bufferevent_ssl_state state,
-    enum bufferevent_options options)
+    int options)
 {
        int close_flag = options & BEV_OPT_CLOSE_ON_FREE;
        BIO *bio;
@@ -1143,7 +1143,7 @@ bufferevent_openssl_socket_new(struct event_base *base,
     evutil_socket_t fd,
     SSL *ssl,
     enum bufferevent_ssl_state state,
-    enum bufferevent_options options)
+    int options)
 {
        /* Does the SSL already have an fd? */
        BIO *bio = SSL_get_wbio(ssl);
index c0d62edacdb8df12ba9ee1ebb6878e3d0f6bc8ee..1081975a52a289ec846389481d24874389a2c746 100644 (file)
@@ -92,7 +92,7 @@ static void be_pair_outbuf_cb(struct evbuffer *,
 
 static struct bufferevent_pair *
 bufferevent_pair_elt_new(struct event_base *base,
-    enum bufferevent_options options)
+    int options)
 {
        struct bufferevent_pair *bufev;
        if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair))))
@@ -113,11 +113,11 @@ bufferevent_pair_elt_new(struct event_base *base,
 }
 
 int
-bufferevent_pair_new(struct event_base *base, enum bufferevent_options options,
+bufferevent_pair_new(struct event_base *base, int options,
     struct bufferevent *pair[2])
 {
         struct bufferevent_pair *bufev1 = NULL, *bufev2 = NULL;
-       enum bufferevent_options tmp_options;
+       int tmp_options;
 
        options |= BEV_OPT_DEFER_CALLBACKS;
        tmp_options = options & ~BEV_OPT_THREADSAFE;
index 5ffed2fce4a080c9436ecf3c23d8ea6032335cd5..2f591bd2f5f47bd4a4474e979e587c2ca09918b3 100644 (file)
@@ -261,7 +261,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
 
 struct bufferevent *
 bufferevent_socket_new(struct event_base *base, evutil_socket_t fd,
-    enum bufferevent_options options)
+    int options)
 {
        struct bufferevent_private *bufev_p;
        struct bufferevent *bufev;
diff --git a/event.c b/event.c
index df0d2669a953ecb80729281250b2eff2e2227980..a612812117ffd0b4a027f6c7a6049ab65837a190 100644 (file)
--- a/event.c
+++ b/event.c
@@ -230,7 +230,7 @@ event_is_method_disabled(const char *name)
        return (getenv(environment) != NULL);
 }
 
-enum event_method_feature
+int
 event_base_get_features(struct event_base *base)
 {
        return base->evsel->features;
@@ -533,8 +533,7 @@ event_config_free(struct event_config *cfg)
 
 
 int
-event_config_set_flag(struct event_config *cfg,
-    enum event_base_config_flag flag)
+event_config_set_flag(struct event_config *cfg, int flag)
 {
        if (!cfg)
                return -1;
@@ -561,7 +560,7 @@ event_config_avoid_method(struct event_config *cfg, const char *method)
 
 int
 event_config_require_features(struct event_config *cfg,
-                              enum event_method_feature features)
+                              int features)
 {
        if (!cfg)
                return (-1);
index f8eae4024b9c3126918cb183cf83c793d2c82d93..dd311853c31a7fa7ba981efc193bc4523078b46b 100644 (file)
@@ -141,7 +141,7 @@ enum bufferevent_options {
           error occurred
   @see bufferevent_free()
   */
-struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, enum bufferevent_options options);
+struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options);
 
 /**
    Launch a connect() attempt with a socket.  When the connect succeeds,
@@ -451,7 +451,7 @@ struct bufferevent *
 bufferevent_filter_new(struct bufferevent *underlying,
                       bufferevent_filter_cb input_filter,
                       bufferevent_filter_cb output_filter,
-                      enum bufferevent_options options,
+                      int options,
                       void (*free_context)(void *),
                       void *ctx);
 
@@ -466,7 +466,7 @@ bufferevent_filter_new(struct bufferevent *underlying,
    @return 0 on success, -1 on failure.
  */
 int
-bufferevent_pair_new(struct event_base *base, enum bufferevent_options options,
+bufferevent_pair_new(struct event_base *base, int options,
     struct bufferevent *pair[2]);
 
 #ifdef __cplusplus
index 0f5e5898dc64b43a920440b8bf4e2e4b3985196f..1ae4f61131dbb25d281bfe32accfaaa9c73134d9 100644 (file)
@@ -53,14 +53,14 @@ bufferevent_openssl_filter_new(struct event_base *base,
     struct bufferevent *underlying,
     struct ssl_st *ssl,
     enum bufferevent_ssl_state state,
-    enum bufferevent_options options);
+    int options);
 
 struct bufferevent *
 bufferevent_openssl_socket_new(struct event_base *base,
     evutil_socket_t fd,
     struct ssl_st *ssl,
     enum bufferevent_ssl_state state,
-    enum bufferevent_options options);
+    int options);
 
 struct ssl_st *
 bufferevent_openssl_get_ssl(struct bufferevent *bufev);
index 8fe1ba56161ea3f43240b8d1a92342a9d9090ada..1a96260df923163dd670dd56d145ab848a25cbd0 100644 (file)
@@ -171,7 +171,7 @@ enum event_base_config_flag {
 /**
  Return a bitmask of the features implemented by an event base.
  */
-enum event_method_feature event_base_get_features(struct event_base *base);
+int event_base_get_features(struct event_base *base);
 
 /**
    Enters a required event method feature that the application demands.
@@ -194,13 +194,11 @@ enum event_method_feature event_base_get_features(struct event_base *base);
           Replaces values from previous calls to this function.
    @return 0 on success, -1 on failure.
 */
-int event_config_require_features(struct event_config *cfg,
-                                  enum event_method_feature feature);
+int event_config_require_features(struct event_config *cfg, int feature);
 
 /** Sets a flag to configure what parts of the eventual event_base will
  * be initialized, and how they'll work. */
-int event_config_set_flag(struct event_config *cfg,
-    enum event_base_config_flag flag);
+int event_config_set_flag(struct event_config *cfg, int flag);
 
 /**
   Initialize the event API.