forked from msysgit/git
-
Notifications
You must be signed in to change notification settings - Fork 10
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 msysgit#156 from kblees/kb/symlinks
Symlink support
- Loading branch information
Showing
11 changed files
with
569 additions
and
204 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
#ifndef LAZYLOAD_H | ||
#define LAZYLOAD_H | ||
|
||
/* simplify loading of DLL functions */ | ||
|
||
struct proc_addr { | ||
const char *const dll; | ||
const char *const function; | ||
FARPROC pfunction; | ||
unsigned initialized : 1; | ||
}; | ||
|
||
/* Declares a function to be loaded dynamically from a DLL. */ | ||
#define DECLARE_PROC_ADDR(dll, rettype, function, ...) \ | ||
static struct proc_addr proc_addr_##function = \ | ||
{ #dll, #function, NULL, 0 }; \ | ||
static rettype (WINAPI *function)(__VA_ARGS__) | ||
|
||
/* | ||
* Loads a function from a DLL (once-only). | ||
* Returns non-NULL function pointer on success. | ||
* Returns NULL + errno == ENOSYS on failure. | ||
*/ | ||
#define INIT_PROC_ADDR(function) (function = get_proc_addr(&proc_addr_##function)) | ||
|
||
static inline void *get_proc_addr(struct proc_addr *proc) | ||
{ | ||
/* only do this once */ | ||
if (!proc->initialized) { | ||
HANDLE hnd; | ||
proc->initialized = 1; | ||
hnd = LoadLibraryExA(proc->dll, NULL, | ||
LOAD_LIBRARY_SEARCH_SYSTEM32); | ||
if (hnd) | ||
proc->pfunction = GetProcAddress(hnd, proc->function); | ||
} | ||
/* set ENOSYS if DLL or function was not found */ | ||
if (!proc->pfunction) | ||
errno = ENOSYS; | ||
return proc->pfunction; | ||
} | ||
|
||
#endif |
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