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.
 
 
 
 

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