You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2012/02/27 18:35:42 UTC

git commit: Use a single conditional for a typedef

Updated Branches:
  refs/heads/R15B-driver bc5a35587 -> b33ce0fac


Use a single conditional for a typedef

Erlang R15B redefines the signature for the driver control callback to
use its own special ssize_t type. This just adds a conditional based on
the definition of ERL_DRV_EXTENDED_MAJOR_VERSION to pick the right type.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b33ce0fa
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b33ce0fa
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b33ce0fa

Branch: refs/heads/R15B-driver
Commit: b33ce0facf0dcf926e34cdfc31a0a6b5d237796b
Parents: bc5a355
Author: Paul Joseph Davis <da...@apache.org>
Authored: Mon Feb 27 11:34:13 2012 -0600
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Mon Feb 27 11:34:19 2012 -0600

----------------------------------------------------------------------
 src/couchdb/priv/icu_driver/couch_icu_driver.c |   27 +++++++++----------
 1 files changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b33ce0fa/src/couchdb/priv/icu_driver/couch_icu_driver.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/icu_driver/couch_icu_driver.c b/src/couchdb/priv/icu_driver/couch_icu_driver.c
index 145c714..27ff5a5 100644
--- a/src/couchdb/priv/icu_driver/couch_icu_driver.c
+++ b/src/couchdb/priv/icu_driver/couch_icu_driver.c
@@ -30,6 +30,12 @@ specific language governing permissions and limitations under the License.
 #include <string.h> /* for memcpy */
 #endif
 
+#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
+typedef unsigned int COUCH_SSIZET;
+#else
+typedef ErlDrvSSizeT COUCH_SSIZET;
+#endif
+
 typedef struct {
     ErlDrvPort port;
     UCollator* collNoCase;
@@ -79,13 +85,9 @@ static ErlDrvData couch_drv_start(ErlDrvPort port, char *buff)
     return (ErlDrvData)pData;
 }
 
-#if ERL_DRV_EXTENDED_MAJOR_VERSION == 1
-// < R15B
-int return_control_result(void* pLocalResult, int localLen, char **ppRetBuf, int returnLen)
-#else
-// >= R15B
-ErlDrvSSizeT return_control_result(void* pLocalResult, int localLen, char **ppRetBuf, ErlDrvSizeT returnLen)
-#endif
+COUCH_SSIZET
+return_control_result(void* pLocalResult, int localLen,
+            char **ppRetBuf, COUCH_SSIZET returnLen)
 {
     if (*ppRetBuf == NULL || localLen > returnLen) {
         *ppRetBuf = (char*)driver_alloc_binary(localLen);
@@ -97,13 +99,10 @@ ErlDrvSSizeT return_control_result(void* pLocalResult, int localLen, char **ppRe
     return localLen;
 }
 
-#if ERL_DRV_EXTENDED_MAJOR_VERSION == 1
-// < R15B
-static int couch_drv_control(ErlDrvData drv_data, unsigned int command, char *pBuf, int bufLen, char **rbuf, int rlen)
-#else
-// >= R15B
-ErlDrvSSizeT couch_drv_control(ErlDrvData drv_data, unsigned int command, char *pBuf, ErlDrvSizeT bufLen, char **rbuf, ErlDrvSizeT rlen)
-#endif
+static COUCH_SSIZET
+couch_drv_control(ErlDrvData drv_data, unsigned int command,
+        char *pBuf, COUCH_SSIZET bufLen,
+        char **rbuf, COUCH_SSIZET rlen)
 {
 
     couch_drv_data* pData = (couch_drv_data*)drv_data;