-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 3ds-libdl. #101
Open
TSnake41
wants to merge
3
commits into
devkitPro:master
Choose a base branch
from
TSnake41:3ds-libdl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add 3ds-libdl. #101
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Contributor: Teddy Astie <[email protected]> | ||
# Maintainer: | ||
|
||
pkgname=3ds-libdl | ||
pkgver=1.0.0 | ||
pkgrel=1 | ||
pkgdesc='Extensible libdl library for projects that needs it.' | ||
arch=('any') | ||
options=(!strip) | ||
makedepends=('devkitpro-pkgbuild-helpers') | ||
source=('dlfcn.c' 'dlfcn.h') | ||
sha256sums=('9c84be0ef4365a3b2ed3948426ecfbdf8116611d63d5ec42d4af8a551c20ef72' '37c16bc645be27cad69904a53973a8862c37890f7327f6b26998794c62527336') | ||
groups=('3ds-portlibs') | ||
|
||
build() { | ||
source /opt/devkitpro/3dsvars.sh | ||
|
||
arm-none-eabi-gcc $CFLAGS -c -o dlfcn.o dlfcn.c | ||
arm-none-eabi-ar rcu libdl.a dlfcn.o | ||
TSnake41 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
package() { | ||
source /opt/devkitpro/3dsvars.sh | ||
mkdir -p $pkgdir$PORTLIBS_PREFIX/lib/ $pkgdir$PORTLIBS_PREFIX/include | ||
TSnake41 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cp libdl.a $pkgdir$PORTLIBS_PREFIX/lib/ | ||
cp dlfcn.h $pkgdir$PORTLIBS_PREFIX/include/ | ||
} |
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,36 @@ | ||
#include "dlfcn.h" | ||
|
||
#include <stddef.h> | ||
|
||
static dl_open open = NULL; | ||
TSnake41 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
static dl_error error = NULL; | ||
static dl_sym sym = NULL; | ||
static dl_close close = NULL; | ||
|
||
void dl_setfn(dl_open new_open, dl_error new_error, dl_sym new_sym, dl_close new_close) | ||
{ | ||
open = new_open; | ||
error = new_error; | ||
sym = new_sym; | ||
close = new_close; | ||
} | ||
|
||
void *dlopen(const char *module, int flag) | ||
{ | ||
return open ? (*open)(module, flag) : NULL; | ||
TSnake41 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
char *dlerror(void) | ||
{ | ||
return error ? (*error)() : ""; | ||
} | ||
|
||
void *dlsym(void *handle, const char *name) | ||
{ | ||
return sym ? (*sym)(handle, name) : NULL; | ||
} | ||
|
||
int dlclose(void *handle) | ||
{ | ||
return close ? (*close)(handle) : 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef __DLFCN_H__ | ||
#define __DLFCN_H__ | ||
|
||
#define RTLD_LAZY 0 | ||
#define RTLD_NOW 1 | ||
#define RTLD_GLOBAL 2 | ||
#define RTLD_LOCAL 3 | ||
|
||
/* Defines a dlfcn.h compatible API. */ | ||
void *dlopen(const char *module, int flag); | ||
char *dlerror(void); | ||
void *dlsym(void *handle, const char *name); | ||
int dlclose(void *handle); | ||
|
||
/* Add a custom API to change builtin functions with user-provided ones. | ||
* This is useful to expand dlfcn to something working when needed (e.g LuaJIT FFI). | ||
*/ | ||
typedef void *(*dl_open)(const char *, int); | ||
typedef char *(*dl_error)(void); | ||
typedef void *(*dl_sym)(void *, const char *); | ||
typedef int (*dl_close)(void *); | ||
|
||
void dl_setfn(dl_open open, dl_error error, dl_sym sym, dl_close close); | ||
|
||
#endif /* __DLFCN_H__ */ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use
$(CC)
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${CC} is currently not defined in 3dsvars.sh, however, ${TOOL_PREFIX} is defined to
arm-none-eabi-
and is actually used to define ${AR}, so to get ${CC}, and can use ${TOOL_PREFIX}gcc.