-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes; update data; get rid of placeholder functionality; add lambda.…
…h; make make_kernel_patchfile use b_relocate instead, whee
- Loading branch information
Showing
14 changed files
with
162 additions
and
335 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
/* Example: | ||
int multiplier = 5; | ||
DECL_LAMBDA(l, int, (int a), { | ||
return a * multiplier; | ||
}) | ||
assert(l.func(l.arg, 4) == 20); | ||
The point of this is to work on both iOS, where GCC inline | ||
functions don't work, and Linux, where Apple blocks generally | ||
aren't available. | ||
*/ | ||
|
||
#ifdef __BLOCKS__ | ||
struct _blk { | ||
void *isa; | ||
int flags; | ||
int reserved; | ||
void *invoke; | ||
}; | ||
#define LAMBDA_BODY(typ, ret, args, body) \ | ||
({ union { \ | ||
ret (^blk) args; \ | ||
struct _blk *_blk; \ | ||
void *vp; \ | ||
} u = { ^ret args body }; \ | ||
(typ) {u._blk->invoke, u.vp}; \ | ||
}) | ||
#else | ||
#define LAMBDA_BODY_(typ, ret, args, body) \ | ||
({ ret func args body; \ | ||
(typ) {&func, 0}; \ | ||
}) | ||
#define LAMBDA_BODY(typ, ret, args, body) \ | ||
LAMBDA_BODY_(typ, ret, LAMBDA_UNPAREN args, body) | ||
#endif | ||
#define LAMBDA_UNPAREN(args...) (void *_lambda_ignored, ##args) | ||
#define DECL_LAMBDA(name, ret, args, body) \ | ||
struct { \ | ||
ret (*func) LAMBDA_UNPAREN args; \ | ||
void *arg; \ | ||
} name = LAMBDA_BODY(typeof(name), ret, args, body); |
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
Oops, something went wrong.