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.
 
 
 
 

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