Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
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.
 
 
 
 

115 lines
2.3 KiB

  1. #include "fmt.h"
  2. #include "scan.h"
  3. #include "str.h"
  4. #include "uint16.h"
  5. #include "uint32.h"
  6. #include "stralloc.h"
  7. #include "socket.h"
  8. #include "buffer.h"
  9. #include "ip4.h"
  10. #include "mmap.h"
  11. #include <stdio.h>
  12. #define rdtscl(low) \
  13. __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
  14. int main(int argc,char* argv[]) {
  15. buffer_putspace(buffer_1);
  16. buffer_flush(buffer_1);
  17. #if 0
  18. long a,b,c;
  19. char buf[4096];
  20. char buf2[4096];
  21. memcpy(buf,buf2,4096);
  22. byte_copy(buf,4096,buf2);
  23. rdtscl(a);
  24. memcpy(buf,buf2,4096);
  25. rdtscl(b);
  26. byte_copy(buf,4096,buf2);
  27. rdtscl(c);
  28. printf("memcpy: %d - byte_copy: %d\n",b-a,c-b);
  29. #endif
  30. #if 0
  31. char ip[16];
  32. int i;
  33. if ((i=scan_ip6(argv[1],ip))) {
  34. char buf[128];
  35. buf[fmt_ip6(buf,ip)]=0;
  36. puts(buf);
  37. }
  38. #endif
  39. #if 0
  40. char buf[100];
  41. strcpy(buf,"foobarbaz");
  42. buf[fmt_fill(buf,3,5,100)]=0;
  43. printf("\"%s\"\n",buf);
  44. #endif
  45. #if 0
  46. unsigned long len;
  47. char *c=mmap_read("/etc/passwd",&len);
  48. printf("got map %p of len %lu\n",c,len);
  49. #endif
  50. #if 0
  51. char c;
  52. printf("%d\n",buffer_getc(buffer_0,&c));
  53. printf("%c\n",c);
  54. #endif
  55. #if 0
  56. char buf[100]="01234567890123456789012345678901234567890123456789";
  57. long a,b,c;
  58. #endif
  59. #if 0
  60. buf[ip4_fmt(buf,ip4loopback)]=0;
  61. buffer_puts(buffer_1small,buf);
  62. buffer_flush(buffer_1small);
  63. #endif
  64. #if 0
  65. buf[0]=0;
  66. buf[fmt_8long(buf,0)]=0;
  67. puts(buf);
  68. rdtscl(a);
  69. c=str_len(buf);
  70. rdtscl(b);
  71. /*byte_zero_djb(buf,j); */
  72. // printf("\n%lu %d\n",b-a,c);
  73. #endif
  74. #if 0
  75. buffer_puts(buffer_1small,"hello, world\n");
  76. buffer_flush(buffer_1small);
  77. #endif
  78. #if 0
  79. int s=socket_tcp4();
  80. char ip[4]={127,0,0,1};
  81. int t=socket_connect4(s,ip,80);
  82. #endif
  83. #if 0
  84. char buf[100]="foo bar baz fnord ";
  85. char buf2[100]="foo braz fnord";
  86. long a,b,c;
  87. long i=0,j=0,k=0;
  88. double d;
  89. uint32 l,m,n;
  90. stralloc sa={0};
  91. stralloc_copys(&sa,"fnord");
  92. stralloc_catlong0(&sa,-23,5);
  93. stralloc_append(&sa,"\n");
  94. printf("%d %d\n",str_equal("fnord","fnord1"),str_equal("fnord1","fnord"));
  95. write(1,sa.s,sa.len);
  96. printf("%d %d\n",stralloc_starts(&sa,"fnord"),stralloc_starts(&sa,"fnord\na"));
  97. l=0xdeadbeef;
  98. uint32_pack_big((char*)&m,l);
  99. uint32_unpack_big((char*)&m,&n);
  100. printf("%x %x %x\n",l,m,n);
  101. rdtscl(a);
  102. /* i=scan_double("3.1415",&d); */
  103. rdtscl(b);
  104. /*byte_zero_djb(buf,j); */
  105. rdtscl(c);
  106. printf("%lu %lu\n",b-a,c-b);
  107. #endif
  108. }