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.
 
 
 
 

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