Fix: log_level usage on mingw platform
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 3 Jul 2019 21:46:45 +0000 (17:46 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 4 Jul 2019 21:46:29 +0000 (17:46 -0400)
The mingw build was simply broken.

For example:

 mman.c: In function 'mmap_lock':
 mman.c:29:30: error: 'mapping' undeclared (first use in this function)
    29 | #define BT_LOG_OUTPUT_LEVEL (mapping->log_level)
       |                              ^~~~~~~
 ../../src/logging/log.h:165:31: note: in expansion of macro 'BT_LOG_OUTPUT_LEVEL'
   165 |  #define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
       |                               ^~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:671:38: note: in expansion of macro '_BT_LOG_OUTPUT_LEVEL'
   671 |   (BT_LOG_ENABLED((lvl)) && (lvl) >= _BT_LOG_OUTPUT_LEVEL)
       |                                      ^~~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:835:9: note: in expansion of macro 'BT_LOG_ON'
   835 |     if (BT_LOG_ON(lvl)) \
       |         ^~~~~~~~~
 ../../src/logging/log.h:974:4: note: in expansion of macro 'BT_LOG_WRITE'
   974 |    BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
       |    ^~~~~~~~~~~~
 ../../src/logging/log.h:995:24: note: in expansion of macro 'BT_LOGF'
   995 | #define BT_LOGF_STR(s) BT_LOGF("%s", (s))
       |                        ^~~~~~~
 mman.c:122:3: note: in expansion of macro 'BT_LOGF_STR'
   122 |   BT_LOGF_STR("Failed to acquire mmap_mutex.");
       |   ^~~~~~~~~~~
 mman.c:29:30: note: each undeclared identifier is reported only once for each function it appears in
    29 | #define BT_LOG_OUTPUT_LEVEL (mapping->log_level)
       |                              ^~~~~~~
 ../../src/logging/log.h:165:31: note: in expansion of macro 'BT_LOG_OUTPUT_LEVEL'
   165 |  #define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
       |                               ^~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:671:38: note: in expansion of macro '_BT_LOG_OUTPUT_LEVEL'
   671 |   (BT_LOG_ENABLED((lvl)) && (lvl) >= _BT_LOG_OUTPUT_LEVEL)
       |                                      ^~~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:835:9: note: in expansion of macro 'BT_LOG_ON'
   835 |     if (BT_LOG_ON(lvl)) \
       |         ^~~~~~~~~
 ../../src/logging/log.h:974:4: note: in expansion of macro 'BT_LOG_WRITE'
   974 |    BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
       |    ^~~~~~~~~~~~
 ../../src/logging/log.h:995:24: note: in expansion of macro 'BT_LOGF'
   995 | #define BT_LOGF_STR(s) BT_LOGF("%s", (s))
       |                        ^~~~~~~
 mman.c:122:3: note: in expansion of macro 'BT_LOGF_STR'
   122 |   BT_LOGF_STR("Failed to acquire mmap_mutex.");
       |   ^~~~~~~~~~~
 mman.c: In function 'mmap_unlock':
 mman.c:29:30: error: 'mapping' undeclared (first use in this function)
    29 | #define BT_LOG_OUTPUT_LEVEL (mapping->log_level)
       |                              ^~~~~~~
 ../../src/logging/log.h:165:31: note: in expansion of macro 'BT_LOG_OUTPUT_LEVEL'
   165 |  #define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
       |                               ^~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:671:38: note: in expansion of macro '_BT_LOG_OUTPUT_LEVEL'
   671 |   (BT_LOG_ENABLED((lvl)) && (lvl) >= _BT_LOG_OUTPUT_LEVEL)
       |                                      ^~~~~~~~~~~~~~~~~~~~
 ../../src/logging/log.h:835:9: note: in expansion of macro 'BT_LOG_ON'
   835 |     if (BT_LOG_ON(lvl)) \
       |         ^~~~~~~~~
 ../../src/logging/log.h:974:4: note: in expansion of macro 'BT_LOG_WRITE'
   974 |    BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
       |    ^~~~~~~~~~~~
 ../../src/logging/log.h:995:24: note: in expansion of macro 'BT_LOGF'
   995 | #define BT_LOGF_STR(s) BT_LOGF("%s", (s))
       |                        ^~~~~~~
 mman.c:131:3: note: in expansion of macro 'BT_LOGF_STR'
   131 |   BT_LOGF_STR("Failed to release mmap_mutex.");
       |   ^~~~~~~~~~~
 mman.c: At top level:
 mman.c:173:7: error: conflicting types for 'bt_mmap'
   173 | void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
       |       ^~~~~~~
 In file included from mman.c:53:
 ../../src/compat/mman.h:48:7: note: previous declaration of 'bt_mmap' was here
    48 | void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
       |       ^~~~~~~
 mman.c: In function 'bt_mmap':
 mman.c:202:12: error: too many arguments to function 'mapping_create'
   202 |  mapping = mapping_create(log_level);
       |            ^~~~~~~~~~~~~~
 mman.c:73:22: note: declared here
    73 | struct mmap_mapping *mapping_create(void)
       |                      ^~~~~~~~~~~~~~
 make[2]: *** [Makefile:501: mman.lo] Error 1

Change-Id: I71b36504541382cadf09953d9e113adc6c3641b6
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1610
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/common/mmap-align.h
src/compat/mman.c
src/compat/mman.h
src/compat/socket.h
src/plugins/ctf/fs-src/data-stream-file.c
src/plugins/ctf/lttng-live/viewer-connection.c

index 5d91c03523f240c47623a216ea8532b21cf3cb5c..033d6c4a92916ce651fc14590887c52d46d82d5b 100644 (file)
@@ -93,7 +93,7 @@ struct mmap_align *mmap_align(size_t length, int prot,
         */
        mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
        mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length,
-               prot, flags, fd, page_aligned_offset);
+               prot, flags, fd, page_aligned_offset, log_level);
        if (mma->page_aligned_addr == MAP_FAILED) {
                free(mma);
                return MAP_FAILED;
index de1d7b34a4d9bf5b07a39e0a7f28bb8fcd4922f3..72c4cc285aabd22b0f855a50950d66067bbb30fc 100644 (file)
@@ -70,7 +70,7 @@ GHashTable *mmap_mappings = NULL;
 static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static
-struct mmap_mapping *mapping_create(void)
+struct mmap_mapping *mapping_create(int log_level)
 {
        struct mmap_mapping *mapping;
 
@@ -78,6 +78,7 @@ struct mmap_mapping *mapping_create(void)
        if (mapping != NULL) {
                mapping->file_handle = NULL;
                mapping->map_handle = NULL;
+               mapping->log_level = log_level;
        }
 
        return mapping;
@@ -119,7 +120,7 @@ static
 void mmap_lock(int log_level)
 {
        if (pthread_mutex_lock(&mmap_mutex)) {
-               BT_LOGF_STR("Failed to acquire mmap_mutex.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_FATAL, log_level, BT_LOG_TAG, "Failed to acquire mmap_mutex.");
                abort();
        }
 }
@@ -128,7 +129,7 @@ static
 void mmap_unlock(int log_level)
 {
        if (pthread_mutex_unlock(&mmap_mutex)) {
-               BT_LOGF_STR("Failed to release mmap_mutex.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_FATAL, log_level, BT_LOG_TAG, "Failed to release mmap_mutex.");
                abort();
        }
 }
index 9f494526617469f5292a7341ee803a5ab26c9cda..bdab9d1903fbab5e08227f4d498cef8de69050c3 100644 (file)
@@ -46,7 +46,7 @@
  * mappings to exceed the file's size (even within a page).
  */
 void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
-       off_t offset);
+       off_t offset, int log_level);
 
 int bt_munmap(void *addr, size_t length);
 
@@ -56,7 +56,7 @@ int bt_munmap(void *addr, size_t length);
 
 static inline
 void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
-       off_t offset)
+       off_t offset, int log_level)
 {
        return (void *) mmap(addr, length, prot, flags, fd, offset);
 }
index b1fe15978a763a2bdbccca238cb19f971ed09c8f..be63d31ebc3edeaa03af27229e8340e78e2c6d55 100644 (file)
@@ -33,7 +33,7 @@
 #define BT_SOCKET SOCKET
 
 static inline
-int bt_socket_init(void)
+int bt_socket_init(int log_level)
 {
        WORD verreq;
        WSADATA wsa;
@@ -44,15 +44,17 @@ int bt_socket_init(void)
 
        ret = WSAStartup(verreq, &wsa);
        if (ret != 0) {
-#ifdef BT_LOGE
-               BT_LOGE("Winsock init failed with error: %d", ret);
+#ifdef BT_LOG_WRITE_CUR_LVL
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                               "Winsock init failed with error: %d", ret);
 #endif
                goto end;
        }
 
        if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wVersion) != 2) {
-#ifdef BT_LOGE_STR
-               BT_LOGE_STR("Could not init winsock 2.2 support");
+#ifdef BT_LOG_WRITE_CUR_LVL
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                               "Could not init winsock 2.2 support");
 #endif
                WSACleanup();
                ret = -1;
@@ -282,7 +284,7 @@ const char *bt_socket_errormsg(void)
 #define BT_SOCKET int
 
 static inline
-int bt_socket_init(void)
+int bt_socket_init(int log_level)
 {
        return 0;
 }
index 880eb852d7f619480a412e6d9b2cc95ef62b5d3e..b4022c32f5804689e0e7886fab82001c97d34650 100644 (file)
@@ -108,7 +108,7 @@ enum bt_msg_iter_medium_status ds_file_mmap_next(
        BT_ASSERT(ds_file->mmap_len);
        ds_file->mmap_addr = bt_mmap((void *) 0, ds_file->mmap_len,
                        PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
-                       ds_file->mmap_offset);
+                       ds_file->mmap_offset, ds_file->log_level);
        if (ds_file->mmap_addr == MAP_FAILED) {
                BT_COMP_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %jd: %s",
                                ds_file->mmap_len, ds_file->file->path->str,
index 0badf75b9565d4456b975e62eb2b946818ba998e..01b4b82315f63b143e4dada262b04a2c38f42ccb 100644 (file)
@@ -1479,7 +1479,7 @@ struct live_viewer_connection *live_viewer_connection_create(
 
        viewer_connection = g_new0(struct live_viewer_connection, 1);
 
-       if (bt_socket_init() != 0) {
+       if (bt_socket_init(lttng_live_msg_iter->log_level) != 0) {
                goto error;
        }
 
This page took 0.028589 seconds and 4 git commands to generate.