-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from LLNL/develop
Release v0.0.7
- Loading branch information
Showing
19 changed files
with
312 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ | |
build | ||
tags | ||
**/tags | ||
*.core | ||
.cache | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GOTCHA_CONFIG_H | ||
#define GOTCHA_CONFIG_H | ||
|
||
#define GOTCHA_GET_VERSION(MAJOR, MINOR, PATCH) (MAJOR * 100000 + MINOR * 100 + PATCH) | ||
#define GOTCHA_VERSION (GOTCHA_GET_VERSION @GOTCHA_VERSION@) | ||
#define GOTCHA_VERSION_MAJOR (GOTCHA_VERSION / 100000) | ||
#define GOTCHA_VERSION_MINOR ((GOTCHA_VERSION / 100) % 1000) | ||
#define GOTCHA_VERSION_PATCH (GOTCHA_VERSION % 100) | ||
|
||
#endif /* GOTCHA_CONFIG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
add_library(impl SHARED libimpl.c) | ||
add_library(dispatcher SHARED libdispatcher.c) | ||
target_link_libraries(dispatcher -ldl -lpthread) | ||
add_executable(test_dispatcher main.c) | ||
target_link_libraries(test_dispatcher gotcha dispatcher) | ||
gotcha_add_test(dispatcher_test test_dispatcher) | ||
set_property(TEST dispatcher_test APPEND PROPERTY ENVIRONMENT "GOTCHA_DEBUG=3") | ||
set_property(TEST dispatcher_test APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
This file is part of GOTCHA. For copyright information see the COPYRIGHT | ||
file in the top level directory, or at | ||
https://github.com/LLNL/gotcha/blob/master/COPYRIGHT | ||
This program is free software; you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (as published by the Free | ||
Software Foundation) version 2.1 dated February 1999. This program is | ||
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the terms and conditions of the GNU Lesser General Public License | ||
for more details. You should have received a copy of the GNU Lesser General | ||
Public License along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#define _GNU_SOURCE | ||
#include <assert.h> | ||
#include <dlfcn.h> | ||
#include <pthread.h> | ||
#include <stdio.h> | ||
|
||
int foo(void); | ||
int bar(void); | ||
|
||
static void* impl_lib; | ||
static int (*impl_foo)(void); | ||
static int (*impl_bar)(void); | ||
|
||
static pthread_once_t init_once = PTHREAD_ONCE_INIT; | ||
void dispatch_init(void) { | ||
fprintf(stderr, "Ed dispatch_init()\n"); | ||
|
||
impl_lib = dlopen("libimpl.so", RTLD_NOW); | ||
assert(impl_lib); | ||
impl_foo = dlsym(impl_lib, "foo"); | ||
assert(impl_foo); | ||
impl_bar = dlsym(impl_lib, "bar"); | ||
assert(impl_bar); | ||
|
||
int ret = impl_bar(); | ||
|
||
fprintf(stderr, "Ld dispatch_init() = %d\n", ret); | ||
} | ||
|
||
int foo(void) { | ||
fprintf(stderr, "Ed foo()\n"); | ||
|
||
pthread_once(&init_once, dispatch_init); | ||
|
||
int ret = impl_bar() + impl_foo(); | ||
|
||
fprintf(stderr, "Ld foo()\n"); | ||
|
||
return ret; | ||
} | ||
|
||
int bar(void) { | ||
fprintf(stderr, "Ed bar()\n"); | ||
|
||
pthread_once(&init_once, dispatch_init); | ||
|
||
int ret = impl_bar(); | ||
|
||
fprintf(stderr, "Ld bar()\n"); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
This file is part of GOTCHA. For copyright information see the COPYRIGHT | ||
file in the top level directory, or at | ||
https://github.com/LLNL/gotcha/blob/master/COPYRIGHT | ||
This program is free software; you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (as published by the Free | ||
Software Foundation) version 2.1 dated February 1999. This program is | ||
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the terms and conditions of the GNU Lesser General Public License | ||
for more details. You should have received a copy of the GNU Lesser General | ||
Public License along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#define _GNU_SOURCE | ||
#include <stdio.h> | ||
|
||
int foo(void) { | ||
fprintf(stderr, "Ei foo()\n"); | ||
fprintf(stderr, "Li foo()\n"); | ||
|
||
return 42; | ||
} | ||
|
||
int bar(void) { | ||
fprintf(stderr, "Ei bar()\n"); | ||
fprintf(stderr, "Li bar()\n"); | ||
|
||
return 23; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
This file is part of GOTCHA. For copyright information see the COPYRIGHT | ||
file in the top level directory, or at | ||
https://github.com/LLNL/gotcha/blob/master/COPYRIGHT | ||
This program is free software; you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (as published by the Free | ||
Software Foundation) version 2.1 dated February 1999. This program is | ||
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the terms and conditions of the GNU Lesser General Public License | ||
for more details. You should have received a copy of the GNU Lesser General | ||
Public License along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#define _GNU_SOURCE | ||
#include <gotcha/gotcha.h> | ||
#include <stdio.h> | ||
|
||
int foo(void); | ||
int bar(void); | ||
|
||
static gotcha_wrappee_handle_t handle_foo; | ||
static gotcha_wrappee_handle_t handle_bar; | ||
|
||
static int do_foo(void) { | ||
fprintf(stderr, "Ew foo()\n"); | ||
|
||
typeof(&do_foo) orig_foo = gotcha_get_wrappee(handle_foo); | ||
int ret = orig_foo(); | ||
|
||
fprintf(stderr, "Lw foo() = %d\n", ret); | ||
|
||
return ret; | ||
} | ||
|
||
static int do_bar(void) { | ||
fprintf(stderr, "Ew bar()\n"); | ||
|
||
typeof(&do_bar) orig_bar = gotcha_get_wrappee(handle_bar); | ||
int ret = orig_bar(); | ||
|
||
fprintf(stderr, "Lw bar() = %d\n", ret); | ||
|
||
return ret; | ||
} | ||
|
||
static struct gotcha_binding_t bindings[] = { | ||
{"foo", do_foo, &handle_foo}, | ||
{"bar", do_bar, &handle_bar}, | ||
}; | ||
|
||
int main(int ac, char *av[]) { | ||
gotcha_wrap(bindings, 2, "test"); | ||
printf("%d\n", foo()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.