7 #include <sys/syscall.h>
12 #include <sys/domain.h>
13 #include <xtypes/domain.h>
14 #include <xseg/domain.h>
16 #include <xtypes/xlock.h>
18 int (*xseg_snprintf)(char *str, size_t size, const char *format, ...) = snprintf;
20 char __xseg_errbuf[4096];
22 static struct xlock __lock = { .owner = Noone};
24 void __lock_domain(void)
26 (void)xlock_acquire(&__lock, 1);
29 void __unlock_domain(void)
31 xlock_release(&__lock);
34 void __load_plugin(const char *name)
39 unsigned int namelen = strlen(name);
41 strncpy(_name, "xseg_", 5);
42 strncpy(_name + 5, name, 80);
43 strncpy(_name + 5 + namelen, ".so", 3);
44 _name[5 + namelen + 3 ] = 0;
45 dl = dlopen(_name, RTLD_NOW);
47 XSEGLOG("Cannot load plugin '%s': %s\n", _name, dlerror());
51 strncpy(_name + 5 + namelen, "_init", 5);
53 init = (void (*)(void))(long)dlsym(dl, _name);
55 XSEGLOG("Init function '%s' not found!\n", _name);
60 //XSEGLOG("Plugin '%s' loaded.\n", name);
63 uint64_t __get_id(void)
65 return (uint64_t)syscall(SYS_gettid);
68 void __xseg_log(const char *msg)
73 void *xtypes_malloc(unsigned long size)
78 void xtypes_free(void *ptr)
83 void __get_current_time(struct timeval *tv) {
84 gettimeofday(tv, NULL);