projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: log_level usage on mingw platform
[babeltrace.git]
/
src
/
compat
/
mman.c
diff --git
a/src/compat/mman.c
b/src/compat/mman.c
index d0cea9df10fc50f0912269fe0aeb8ff0648924f0..72c4cc285aabd22b0f855a50950d66067bbb30fc 100644
(file)
--- a/
src/compat/mman.c
+++ b/
src/compat/mman.c
@@
-26,8
+26,11
@@
* SOFTWARE.
*/
* SOFTWARE.
*/
-#define BT_LOG_TAG "COMPAT-MMAN"
-#include "logging.h"
+#define BT_LOG_OUTPUT_LEVEL (mapping->log_level)
+#define BT_LOG_TAG "COMPAT/MMAN"
+#include "logging/log.h"
+
+#include "common/macros.h"
#ifdef __APPLE__
/*
#ifdef __APPLE__
/*
@@
-41,13
+44,17
@@
int bt_mman_dummy_symbol;
#ifdef __MINGW32__
#include <errno.h>
#ifdef __MINGW32__
#include <errno.h>
+#include <glib.h>
#include <io.h>
#include <pthread.h>
#include <stdlib.h>
#include <windows.h>
#include <io.h>
#include <pthread.h>
#include <stdlib.h>
#include <windows.h>
+
#include "compat/mman.h"
struct mmap_mapping {
#include "compat/mman.h"
struct mmap_mapping {
+ int log_level;
+
/* The duplicated handle. */
HANDLE file_handle;
/* Handle returned by CreateFileMapping. */
/* The duplicated handle. */
HANDLE file_handle;
/* Handle returned by CreateFileMapping. */
@@
-63,7
+70,7
@@
GHashTable *mmap_mappings = NULL;
static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER;
static
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;
{
struct mmap_mapping *mapping;
@@
-71,6
+78,7
@@
struct mmap_mapping *mapping_create(void)
if (mapping != NULL) {
mapping->file_handle = NULL;
mapping->map_handle = NULL;
if (mapping != NULL) {
mapping->file_handle = NULL;
mapping->map_handle = NULL;
+ mapping->log_level = log_level;
}
return mapping;
}
return mapping;
@@
-98,25
+106,30
@@
void addr_clean(void *addr)
{
/* Cleanup of handles should never fail. */
if (!UnmapViewOfFile(addr)) {
{
/* Cleanup of handles should never fail. */
if (!UnmapViewOfFile(addr)) {
- BT_LOGF_STR("Failed to unmap mmap mapping.");
+ /*
+ * FIXME: We don't have access to the mapping's log
+ * level here, so force a FATAL level.
+ */
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_FATAL, BT_LOG_FATAL, BT_LOG_TAG,
+ "Failed to unmap mmap mapping.");
abort();
}
}
static
abort();
}
}
static
-void mmap_lock(
void
)
+void mmap_lock(
int log_level
)
{
if (pthread_mutex_lock(&mmap_mutex)) {
{
if (pthread_mutex_lock(&mmap_mutex)) {
- BT_LOG
F_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();
}
}
static
abort();
}
}
static
-void mmap_unlock(
void
)
+void mmap_unlock(
int log_level
)
{
if (pthread_mutex_unlock(&mmap_mutex)) {
{
if (pthread_mutex_unlock(&mmap_mutex)) {
- BT_LOG
F_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();
}
}
abort();
}
}
@@
-159,7
+172,7
@@
DWORD map_prot_flags(int prot, DWORD *dwDesiredAccess)
BT_HIDDEN
void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
BT_HIDDEN
void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
- off_t offset)
+ off_t offset
, int log_level
)
{
struct mmap_mapping *mapping = NULL;
void *mapping_addr;
{
struct mmap_mapping *mapping = NULL;
void *mapping_addr;
@@
-187,9
+200,10
@@
void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
}
/* Allocate the mapping struct. */
}
/* Allocate the mapping struct. */
- mapping = mapping_create();
+ mapping = mapping_create(
log_level
);
if (!mapping) {
if (!mapping) {
- BT_LOGE_STR("Failed to allocate mmap mapping.");
+ BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+ "Failed to allocate mmap mapping.");
_set_errno(ENOMEM);
goto error;
}
_set_errno(ENOMEM);
goto error;
}
@@
-229,7
+243,7
@@
void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
goto error;
}
goto error;
}
- mmap_lock();
+ mmap_lock(
log_level
);
/* If we have never done any mappings, allocate the hashtable. */
if (!mmap_mappings) {
/* If we have never done any mappings, allocate the hashtable. */
if (!mmap_mappings) {
@@
-246,12
+260,12
@@
void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
/* Add the new mapping to the hashtable. */
g_hash_table_insert(mmap_mappings, mapping_addr, mapping);
/* Add the new mapping to the hashtable. */
g_hash_table_insert(mmap_mappings, mapping_addr, mapping);
- mmap_unlock();
+ mmap_unlock(
log_level
);
return mapping_addr;
error_mutex_unlock:
return mapping_addr;
error_mutex_unlock:
- mmap_unlock();
+ mmap_unlock(
log_level
);
error:
mapping_clean(mapping);
return MAP_FAILED;
error:
mapping_clean(mapping);
return MAP_FAILED;
@@
-261,8
+275,12
@@
BT_HIDDEN
int bt_munmap(void *addr, size_t length)
{
int ret = 0;
int bt_munmap(void *addr, size_t length)
{
int ret = 0;
+ struct mmap_mapping *mapping = addr;
+ int log_level;
- mmap_lock();
+ BT_ASSERT(mapping);
+ log_level = mapping->log_level;
+ mmap_lock(log_level);
/* Check if the mapping exists in the hashtable. */
if (g_hash_table_lookup(mmap_mappings, addr) == NULL) {
/* Check if the mapping exists in the hashtable. */
if (g_hash_table_lookup(mmap_mappings, addr) == NULL) {
@@
-278,7
+296,7
@@
int bt_munmap(void *addr, size_t length)
}
end:
}
end:
- mmap_unlock();
+ mmap_unlock(
log_level
);
return ret;
}
return ret;
}
This page took
0.026766 seconds
and
4
git commands to generate.