A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

gccgo_c.c 1014B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build gccgo
  5. #include <errno.h>
  6. #include <stdint.h>
  7. #include <unistd.h>
  8. #define _STRINGIFY2_(x) #x
  9. #define _STRINGIFY_(x) _STRINGIFY2_(x)
  10. #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
  11. // Call syscall from C code because the gccgo support for calling from
  12. // Go to C does not support varargs functions.
  13. struct ret {
  14. uintptr_t r;
  15. uintptr_t err;
  16. };
  17. struct ret
  18. gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
  19. {
  20. struct ret r;
  21. errno = 0;
  22. r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  23. r.err = errno;
  24. return r;
  25. }
  26. // Define the use function in C so that it is not inlined.
  27. extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
  28. void
  29. use(void *p __attribute__ ((unused)))
  30. {
  31. }