Overview
| Artifact ID: | d3564d3320ce3aa0fa08cb476a7662d2a2ce011009c90471cd4de31ff8a3613c |
|---|---|
| Ticket: | 26f1328a86863216c8fae28f55ff0e09135d5d35 |
| Date: | 2022-01-12 13:01:28 |
| User: | anonymous |
| Artifact Attached: | 9353a436964c440c54a83e2ccfff7c40c3ae439318ddd5f70683500921f83c19 |
| Filename: | test-signed-tcl.c |
| Description: |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32#include <stdio.h> #define is_unsigned(n) ((n) >= 0 && ((n)-(n)-1) >= 0) #define TclGetUInt1AtPtr(p) \ ((unsigned int) *(p)) #define TclGetInt4AtPtr(p) \ (((int) (TclGetUInt1AtPtr(p) << 24)) | \ (*((p)+1) << 16) | \ (*((p)+2) << 8) | \ (*((p)+3))) int main (void) { // Baseline printf("12 -> U:%d\n", is_unsigned(12)); printf("12U -> U:%d\n", is_unsigned(12U)); printf("-12 -> U:%d\n", is_unsigned(-12)); unsigned char * pc = (unsigned char*)main; unsigned char bytes[] = {0xFF,0xFF,0xFD,0xBC}; printf("int(bytes): %d U:%d\n", TclGetInt4AtPtr(bytes), is_unsigned(TclGetInt4AtPtr(bytes))); printf("ptr: %p + int(bytes) -> %p (diff:%lld)\n", pc, pc + TclGetInt4AtPtr(bytes), (long long) ((pc + TclGetInt4AtPtr(bytes)) - pc)); return 0; }
