This is a maintenance fork
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
2.3 KiB

1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
  1. /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
  2. vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
  3. Copyright 2020 Justine Alexandra Roberts Tunney
  4. Permission to use, copy, modify, and/or distribute this software for
  5. any purpose with or without fee is hereby granted, provided that the
  6. above copyright notice and this permission notice appear in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  8. WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  9. WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  10. AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  12. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  13. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  14. PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "libc/fmt/conv.h"
  17. #include "libc/runtime/interruptiblecall.h"
  18. #include "libc/stdio/stdio.h"
  19. #include "libc/sysv/consts/sig.h"
  20. struct InterruptibleCall icall;
  21. static intptr_t peek(intptr_t *addr) {
  22. return *addr;
  23. }
  24. int main(int argc, char *argv[]) {
  25. int i;
  26. for (i = 1; i < argc; ++i) {
  27. intptr_t addr = strtoul(argv[i], NULL, 0);
  28. icall.sig = SIGSEGV;
  29. printf("%#p → %#lx\n", addr,
  30. interruptiblecall(&icall, (void *)peek, addr, 0, 0, 0));
  31. }
  32. return 0;
  33. }