Line data Source code
1 : #include "fd_tango.h"
2 : #include "mcache/fd_mcache_private.h"
3 : #include "dcache/fd_dcache_private.h"
4 :
5 : #if FD_HAS_HOSTED
6 :
7 : #include <stdio.h>
8 :
9 : FD_IMPORT_CSTR( fd_tango_ctl_help, "src/tango/fd_tango_ctl_help" );
10 :
11 : int
12 : main( int argc,
13 0 : char ** argv ) {
14 0 : fd_boot( &argc, &argv );
15 0 : # define SHIFT(n) argv+=(n),argc-=(n)
16 :
17 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "no arguments" ));
18 0 : char const * bin = argv[0];
19 0 : SHIFT(1);
20 :
21 : /* FIXME: CACHE ATTACHMENTS? */
22 :
23 0 : ulong tag = 1UL;
24 :
25 0 : int cnt = 0;
26 0 : while( argc ) {
27 0 : char const * cmd = argv[0];
28 0 : SHIFT(1);
29 :
30 0 : if( !strcmp( cmd, "help" ) ) {
31 :
32 0 : fputs( fd_tango_ctl_help, stdout );
33 :
34 0 : FD_LOG_NOTICE(( "%i: %s: success", cnt, cmd ));
35 :
36 0 : } else if( !strcmp( cmd, "tag" ) ) {
37 :
38 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
39 :
40 0 : tag = fd_cstr_to_ulong( argv[0] );
41 :
42 0 : FD_LOG_NOTICE(( "%i: %s %lu: success", cnt, cmd, tag ));
43 0 : SHIFT(1);
44 :
45 0 : } else if( !strcmp( cmd, "new-mcache" ) ) {
46 :
47 0 : if( FD_UNLIKELY( argc<4 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
48 :
49 0 : char const * _wksp = argv[0];
50 0 : ulong depth = fd_cstr_to_ulong( argv[1] );
51 0 : ulong app_sz = fd_cstr_to_ulong( argv[2] );
52 0 : ulong seq0 = fd_cstr_to_ulong( argv[3] );
53 :
54 0 : ulong align = fd_mcache_align();
55 0 : ulong footprint = fd_mcache_footprint( depth, app_sz );
56 0 : if( FD_UNLIKELY( !footprint ) )
57 0 : FD_LOG_ERR(( "%i: %s: depth (%lu) must a power-of-2 and at least %lu and depth and app_sz (%lu) must result in a "
58 0 : "footprint smaller than 2^64.\n\tDo %s help for help", cnt, cmd, depth, FD_MCACHE_BLOCK, app_sz, bin ));
59 :
60 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
61 0 : if( FD_UNLIKELY( !wksp ) ) {
62 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
63 0 : }
64 :
65 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
66 0 : if( FD_UNLIKELY( !gaddr ) ) {
67 0 : fd_wksp_detach( wksp );
68 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
69 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
70 0 : }
71 :
72 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
73 0 : if( FD_UNLIKELY( !shmem ) ) {
74 0 : fd_wksp_free( wksp, gaddr );
75 0 : fd_wksp_detach( wksp );
76 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
77 0 : }
78 :
79 0 : void * shmcache = fd_mcache_new( shmem, depth, app_sz, seq0 );
80 0 : if( FD_UNLIKELY( !shmcache ) ) {
81 0 : fd_wksp_free( wksp, gaddr );
82 0 : fd_wksp_detach( wksp );
83 0 : FD_LOG_ERR(( "%i: %s: fd_mcache_new( %s:%lu, %lu, %lu, %lu ) failed\n\tDo %s help for help",
84 0 : cnt, cmd, _wksp, gaddr, depth, app_sz, seq0, bin ));
85 0 : }
86 :
87 0 : char buf[ FD_WKSP_CSTR_MAX ];
88 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
89 :
90 0 : fd_wksp_detach( wksp );
91 :
92 0 : FD_LOG_NOTICE(( "%i: %s %s %lu %lu %lu: success", cnt, cmd, _wksp, depth, app_sz, seq0 ));
93 0 : SHIFT( 4 );
94 :
95 0 : } else if( !strcmp( cmd, "delete-mcache" ) ) {
96 :
97 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
98 :
99 0 : char const * _shmcache = argv[0];
100 :
101 0 : void * shmcache = fd_wksp_map( _shmcache );
102 0 : if( FD_UNLIKELY( !shmcache ) )
103 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
104 0 : if( FD_UNLIKELY( !fd_mcache_delete( shmcache ) ) )
105 0 : FD_LOG_ERR(( "%i: %s: fd_mcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
106 0 : fd_wksp_unmap( shmcache );
107 :
108 0 : fd_wksp_cstr_free( _shmcache );
109 :
110 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shmcache ));
111 0 : SHIFT( 1 );
112 :
113 0 : } else if( !strcmp( cmd, "query-mcache" ) ) {
114 :
115 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
116 :
117 0 : char const * _shmcache = argv[0];
118 0 : int verbose = fd_cstr_to_int( argv[1] );
119 :
120 0 : void * shmcache = fd_wksp_map( _shmcache );
121 0 : if( FD_UNLIKELY( !shmcache ) )
122 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
123 :
124 0 : fd_frag_meta_t const * mcache = fd_mcache_join( shmcache );
125 0 : if( FD_UNLIKELY( !mcache ) )
126 0 : FD_LOG_ERR(( "%i: %s: fd_mcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
127 :
128 0 : fd_mcache_private_hdr_t const * hdr = fd_mcache_private_hdr_const( mcache );
129 0 : if( !verbose ) printf( "%lu\n", *hdr->seq );
130 0 : else {
131 0 : printf( "mcache %s\n", _shmcache );
132 0 : printf( "\tdepth %lu\n", hdr->depth );
133 0 : printf( "\tapp-sz %lu\n", hdr->app_sz );
134 0 : printf( "\tseq0 %lu\n", hdr->seq0 );
135 :
136 0 : ulong seq_cnt;
137 0 : for( seq_cnt=FD_MCACHE_SEQ_CNT; seq_cnt; seq_cnt-- ) if( hdr->seq[seq_cnt-1UL] ) break;
138 0 : printf( "\tseq[ 0] %lu\n", *hdr->seq );
139 0 : for( ulong idx=1UL; idx<seq_cnt; idx++ ) printf( "\tseq[%2lu] %lu\n", idx, hdr->seq[idx] );
140 0 : if( seq_cnt<FD_MCACHE_SEQ_CNT ) printf( "\t ... snip (all remaining are zero) ...\n" );
141 :
142 0 : if( hdr->app_sz ) {
143 0 : uchar const * a = fd_mcache_app_laddr_const( mcache );
144 0 : ulong app_sz;
145 0 : for( app_sz=hdr->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
146 0 : ulong off = 0UL;
147 0 : printf( "\tapp %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
148 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
149 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
150 0 : for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
151 0 : printf( "\t %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
152 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
153 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
154 0 : if( off<hdr->app_sz ) printf( "\t ... snip (all remaining are zero) ...\n" );
155 0 : }
156 0 : }
157 :
158 0 : fd_wksp_unmap( fd_mcache_leave( mcache ) );
159 :
160 0 : FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shmcache, verbose ));
161 0 : SHIFT( 2 );
162 :
163 0 : } else if( !strcmp( cmd, "new-dcache" ) ) {
164 :
165 0 : if( FD_UNLIKELY( argc<6 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
166 :
167 0 : char const * _wksp = argv[0];
168 0 : ulong mtu = fd_cstr_to_ulong( argv[1] );
169 0 : ulong depth = fd_cstr_to_ulong( argv[2] );
170 0 : ulong burst = fd_cstr_to_ulong( argv[3] );
171 0 : int compact = fd_cstr_to_int ( argv[4] );
172 0 : ulong app_sz = fd_cstr_to_ulong( argv[5] );
173 :
174 0 : ulong data_sz = fd_dcache_req_data_sz( mtu, depth, burst, compact );
175 0 : if( FD_UNLIKELY( !data_sz ) ) {
176 0 : FD_LOG_ERR(( "%i: %s: mtu (%lu), depth (%lu), burst (%lu) all must be positive and mtu, depth, burst and compact (%i) "
177 0 : "must result in a data_sz smaller than 2^64.\n\tDo %s help for help",
178 0 : cnt, cmd, mtu, depth, burst, compact, bin ));
179 0 : }
180 :
181 0 : ulong align = fd_dcache_align();
182 0 : ulong footprint = fd_dcache_footprint( data_sz, app_sz );
183 0 : if( FD_UNLIKELY( !footprint ) ) {
184 0 : FD_LOG_ERR(( "%i: %s: mtu (%lu), depth (%lu), burst (%lu), compact (%i) and app_sz (%lu) must result in a footprint "
185 0 : "smaller than 2^64.\n\tDo %s help for help", cnt, cmd, mtu, depth, burst, compact, app_sz, bin ));
186 0 : }
187 :
188 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
189 0 : if( FD_UNLIKELY( !wksp ) ) {
190 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
191 0 : }
192 :
193 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
194 0 : if( FD_UNLIKELY( !gaddr ) ) {
195 0 : fd_wksp_detach( wksp );
196 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
197 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
198 0 : }
199 :
200 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
201 0 : if( FD_UNLIKELY( !shmem ) ) {
202 0 : fd_wksp_free( wksp, gaddr );
203 0 : fd_wksp_detach( wksp );
204 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
205 0 : }
206 :
207 0 : void * shdcache = fd_dcache_new( shmem, data_sz, app_sz );
208 0 : if( FD_UNLIKELY( !shdcache ) ) {
209 0 : fd_wksp_free( wksp, gaddr );
210 0 : fd_wksp_detach( wksp );
211 0 : FD_LOG_ERR(( "%i: %s: fd_dcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
212 0 : cnt, cmd, _wksp, gaddr, data_sz, app_sz, bin ));
213 0 : }
214 :
215 0 : char buf[ FD_WKSP_CSTR_MAX ];
216 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
217 :
218 0 : fd_wksp_detach( wksp );
219 :
220 0 : FD_LOG_NOTICE(( "%i: %s %s %lu %lu %lu %i %lu: success", cnt, cmd, _wksp, mtu, depth, burst, compact, app_sz ));
221 0 : SHIFT( 6 );
222 :
223 0 : } else if( !strcmp( cmd, "new-dcache-raw" ) ) {
224 :
225 0 : if( FD_UNLIKELY( argc<3 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
226 :
227 0 : char const * _wksp = argv[0];
228 0 : ulong data_sz = fd_cstr_to_ulong( argv[1] );
229 0 : ulong app_sz = fd_cstr_to_ulong( argv[2] );
230 :
231 0 : ulong align = fd_dcache_align();
232 0 : ulong footprint = fd_dcache_footprint( data_sz, app_sz );
233 0 : if( FD_UNLIKELY( !footprint ) ) {
234 0 : FD_LOG_ERR(( "%i: %s: data_sz (%lu) and app_sz (%lu) must result a footprint smaller than 2^64.\n\tDo %s help for help",
235 0 : cnt, cmd, data_sz, app_sz, bin ));
236 0 : }
237 :
238 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
239 0 : if( FD_UNLIKELY( !wksp ) ) {
240 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
241 0 : }
242 :
243 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
244 0 : if( FD_UNLIKELY( !gaddr ) ) {
245 0 : fd_wksp_detach( wksp );
246 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
247 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
248 0 : }
249 :
250 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
251 0 : if( FD_UNLIKELY( !shmem ) ) {
252 0 : fd_wksp_free( wksp, gaddr );
253 0 : fd_wksp_detach( wksp );
254 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
255 0 : }
256 :
257 0 : void * shdcache = fd_dcache_new( shmem, data_sz, app_sz );
258 0 : if( FD_UNLIKELY( !shdcache ) ) {
259 0 : fd_wksp_free( wksp, gaddr );
260 0 : fd_wksp_detach( wksp );
261 0 : FD_LOG_ERR(( "%i: %s: fd_dcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
262 0 : cnt, cmd, _wksp, gaddr, data_sz, app_sz, bin ));
263 0 : }
264 :
265 0 : char buf[ FD_WKSP_CSTR_MAX ];
266 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
267 :
268 0 : fd_wksp_detach( wksp );
269 :
270 0 : FD_LOG_NOTICE(( "%i: %s %s %lu %lu: success", cnt, cmd, _wksp, data_sz, app_sz ));
271 0 : SHIFT( 3 );
272 :
273 0 : } else if( !strcmp( cmd, "delete-dcache" ) ) {
274 :
275 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
276 :
277 0 : char const * _shdcache = argv[0];
278 :
279 0 : void * shdcache = fd_wksp_map( _shdcache );
280 0 : if( FD_UNLIKELY( !shdcache ) )
281 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
282 0 : if( FD_UNLIKELY( !fd_dcache_delete( shdcache ) ) )
283 0 : FD_LOG_ERR(( "%i: %s: fd_dcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
284 0 : fd_wksp_unmap( shdcache );
285 :
286 0 : fd_wksp_cstr_free( _shdcache );
287 :
288 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shdcache ));
289 0 : SHIFT( 1 );
290 :
291 0 : } else if( !strcmp( cmd, "query-dcache" ) ) {
292 :
293 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
294 :
295 0 : char const * _shdcache = argv[0];
296 0 : int verbose = fd_cstr_to_int( argv[1] );
297 :
298 0 : void * shdcache = fd_wksp_map( _shdcache );
299 0 : if( FD_UNLIKELY( !shdcache ) )
300 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
301 :
302 0 : uchar const * dcache = fd_dcache_join( shdcache );
303 0 : if( FD_UNLIKELY( !dcache ) )
304 0 : FD_LOG_ERR(( "%i: %s: fd_dcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
305 :
306 0 : if( !verbose ) printf( "0\n" );
307 0 : else {
308 0 : fd_dcache_private_hdr_t const * hdr = fd_dcache_private_hdr_const( dcache );
309 0 : printf( "dcache %s\n", _shdcache );
310 0 : printf( "\tdata-sz %lu\n", hdr->data_sz );
311 0 : printf( "\tapp-sz %lu\n", hdr->app_sz );
312 :
313 0 : if( hdr->app_sz ) {
314 0 : uchar const * a = fd_dcache_app_laddr_const( dcache );
315 0 : ulong app_sz;
316 0 : for( app_sz=hdr->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
317 0 : ulong off = 0UL;
318 0 : printf( "\tapp %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
319 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
320 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
321 0 : for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
322 0 : printf( "\t %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
323 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
324 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
325 0 : if( off<hdr->app_sz ) printf( "\t ... snip (all remaining are zero) ...\n" );
326 0 : }
327 0 : }
328 :
329 0 : fd_wksp_unmap( fd_dcache_leave( dcache ) );
330 :
331 0 : FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shdcache, verbose ));
332 0 : SHIFT( 2 );
333 :
334 0 : } else if( !strcmp( cmd, "new-fseq" ) ) {
335 :
336 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
337 :
338 0 : char const * _wksp = argv[0];
339 0 : ulong seq0 = fd_cstr_to_ulong( argv[1] );
340 :
341 0 : ulong align = fd_fseq_align();
342 0 : ulong footprint = fd_fseq_footprint();
343 :
344 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
345 0 : if( FD_UNLIKELY( !wksp ) ) {
346 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
347 0 : }
348 :
349 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
350 0 : if( FD_UNLIKELY( !gaddr ) ) {
351 0 : fd_wksp_detach( wksp );
352 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
353 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
354 0 : }
355 :
356 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
357 0 : if( FD_UNLIKELY( !shmem ) ) {
358 0 : fd_wksp_free( wksp, gaddr );
359 0 : fd_wksp_detach( wksp );
360 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
361 0 : }
362 :
363 0 : void * shfseq = fd_fseq_new( shmem, seq0 );
364 0 : if( FD_UNLIKELY( !shfseq ) ) {
365 0 : fd_wksp_free( wksp, gaddr );
366 0 : fd_wksp_detach( wksp );
367 0 : FD_LOG_ERR(( "%i: %s: fd_fseq_new( %s:%lu, %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, seq0, bin ));
368 0 : }
369 :
370 0 : char buf[ FD_WKSP_CSTR_MAX ];
371 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
372 :
373 0 : fd_wksp_detach( wksp );
374 :
375 0 : FD_LOG_NOTICE(( "%i: %s %s %lu: success", cnt, cmd, _wksp, seq0 ));
376 0 : SHIFT( 2 );
377 :
378 0 : } else if( !strcmp( cmd, "delete-fseq" ) ) {
379 :
380 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
381 :
382 0 : char const * _shfseq = argv[0];
383 :
384 0 : void * shfseq = fd_wksp_map( _shfseq );
385 0 : if( FD_UNLIKELY( !shfseq ) )
386 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
387 0 : if( FD_UNLIKELY( !fd_fseq_delete( shfseq ) ) )
388 0 : FD_LOG_ERR(( "%i: %s: fd_fseq_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
389 0 : fd_wksp_unmap( shfseq );
390 :
391 0 : fd_wksp_cstr_free( _shfseq );
392 :
393 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shfseq ));
394 0 : SHIFT( 1 );
395 :
396 0 : } else if( !strcmp( cmd, "query-fseq" ) ) {
397 :
398 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
399 :
400 0 : char const * _shfseq = argv[0];
401 0 : int verbose = fd_cstr_to_int( argv[1] );
402 :
403 0 : void * shfseq = fd_wksp_map( _shfseq );
404 0 : if( FD_UNLIKELY( !shfseq ) )
405 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
406 :
407 0 : ulong const * fseq = fd_fseq_join( shfseq );
408 0 : if( FD_UNLIKELY( !fseq ) )
409 0 : FD_LOG_ERR(( "%i: %s: fd_fseq_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
410 :
411 0 : if( !verbose ) printf( "%lu\n", fd_fseq_query( fseq ) );
412 0 : else {
413 0 : printf( "fseq %s\n", _shfseq );
414 0 : printf( "\tseq0 %lu\n", fd_fseq_seq0 ( fseq ) );
415 0 : printf( "\tseq %lu\n", fd_fseq_query( fseq ) );
416 0 : uchar const * a = (uchar const *)fd_fseq_app_laddr_const( fseq );
417 0 : ulong app_sz;
418 0 : for( app_sz=FD_FSEQ_APP_FOOTPRINT; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
419 0 : ulong off = 0UL;
420 0 : printf( "\tapp %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
421 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
422 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
423 0 : for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
424 0 : printf( "\t %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
425 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
426 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
427 0 : if( off<FD_FSEQ_APP_FOOTPRINT ) printf( "\t ... snip (all remaining are zero) ...\n" );
428 0 : }
429 :
430 0 : fd_wksp_unmap( fd_fseq_leave( fseq ) );
431 :
432 0 : FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shfseq, verbose ));
433 0 : SHIFT( 2 );
434 :
435 0 : } else if( !strcmp( cmd, "update-fseq" ) ) {
436 :
437 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
438 :
439 0 : char const * _shfseq = argv[0];
440 0 : ulong seq = fd_cstr_to_ulong( argv[1] );
441 :
442 0 : void * shfseq = fd_wksp_map( _shfseq );
443 0 : if( FD_UNLIKELY( !shfseq ) )
444 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
445 :
446 0 : ulong * fseq = fd_fseq_join( shfseq );
447 0 : if( FD_UNLIKELY( !fseq ) )
448 0 : FD_LOG_ERR(( "%i: %s: fd_fseq_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
449 :
450 0 : fd_fseq_update( fseq, seq );
451 :
452 0 : fd_wksp_unmap( fd_fseq_leave( fseq ) );
453 :
454 0 : FD_LOG_NOTICE(( "%i: %s %s %lu: success", cnt, cmd, _shfseq, seq ));
455 0 : SHIFT( 2 );
456 :
457 0 : } else if( !strcmp( cmd, "new-cnc" ) ) {
458 :
459 0 : if( FD_UNLIKELY( argc<4 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
460 :
461 0 : char const * _wksp = argv[0];
462 0 : ulong type = fd_cstr_to_ulong( argv[1] );
463 0 : long heartbeat = (!strcmp( argv[2], "-" )) ? fd_log_wallclock() :
464 0 : ( (!strcmp( argv[2], "tic" )) ? fd_tickcount() :
465 0 : fd_cstr_to_long ( argv[2] ) );
466 0 : ulong app_sz = fd_cstr_to_ulong( argv[3] );
467 :
468 0 : ulong align = fd_cnc_align();
469 0 : ulong footprint = fd_cnc_footprint( app_sz );
470 0 : if( FD_UNLIKELY( !footprint ) ) {
471 0 : FD_LOG_ERR(( "%i: %s: bad app-sz (%lu)\n\tDo %s help for help", cnt, cmd, app_sz, bin ));
472 0 : }
473 :
474 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
475 0 : if( FD_UNLIKELY( !wksp ) ) {
476 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
477 0 : }
478 :
479 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
480 0 : if( FD_UNLIKELY( !gaddr ) ) {
481 0 : fd_wksp_detach( wksp );
482 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
483 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
484 0 : }
485 :
486 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
487 0 : if( FD_UNLIKELY( !shmem ) ) {
488 0 : fd_wksp_free( wksp, gaddr );
489 0 : fd_wksp_detach( wksp );
490 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
491 0 : }
492 :
493 0 : void * shcnc = fd_cnc_new( shmem, app_sz, type, heartbeat );
494 0 : if( FD_UNLIKELY( !shcnc ) ) {
495 0 : fd_wksp_free( wksp, gaddr );
496 0 : fd_wksp_detach( wksp );
497 0 : FD_LOG_ERR(( "%i: %s: fd_cnc_new( %s:%lu, %lu, %lu, %li ) failed\n\tDo %s help for help",
498 0 : cnt, cmd, _wksp, gaddr, app_sz, type, heartbeat, bin ));
499 0 : }
500 :
501 0 : char buf[ FD_WKSP_CSTR_MAX ];
502 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
503 :
504 0 : fd_wksp_detach( wksp );
505 :
506 0 : FD_LOG_NOTICE(( "%i: %s %s %lu %li %lu: success", cnt, cmd, _wksp, type, heartbeat, app_sz ));
507 0 : SHIFT( 4 );
508 :
509 0 : } else if( !strcmp( cmd, "delete-cnc" ) ) {
510 :
511 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
512 :
513 0 : char const * _shcnc = argv[0];
514 :
515 0 : void * shcnc = fd_wksp_map( _shcnc );
516 0 : if( FD_UNLIKELY( !shcnc ) )
517 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
518 0 : if( FD_UNLIKELY( !fd_cnc_delete( shcnc ) ) )
519 0 : FD_LOG_ERR(( "%i: %s: fd_cnc_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
520 0 : fd_wksp_unmap( shcnc );
521 :
522 0 : fd_wksp_cstr_free( _shcnc );
523 :
524 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shcnc ));
525 0 : SHIFT( 1 );
526 :
527 0 : } else if( !strcmp( cmd, "query-cnc" ) ) {
528 :
529 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
530 :
531 0 : char const * _shcnc = argv[0];
532 0 : int verbose = fd_cstr_to_int( argv[1] );
533 :
534 0 : void * shcnc = fd_wksp_map( _shcnc );
535 0 : if( FD_UNLIKELY( !shcnc ) )
536 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
537 :
538 0 : fd_cnc_t const * cnc = fd_cnc_join( shcnc );
539 0 : if( FD_UNLIKELY( !cnc ) )
540 0 : FD_LOG_ERR(( "%i: %s: fd_cnc_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
541 :
542 0 : char buf[ FD_CNC_SIGNAL_CSTR_BUF_MAX ];
543 :
544 0 : if( !verbose ) printf( "%lu\n", cnc->signal );
545 0 : else {
546 0 : printf( "cnc %s\n", _shcnc );
547 0 : printf( "\tapp-sz %lu\n", cnc->app_sz );
548 0 : printf( "\ttype %lu\n", cnc->type );
549 0 : printf( "\theartbeat0 %li\n", cnc->heartbeat0 );
550 0 : printf( "\theartbeat %li\n", cnc->heartbeat );
551 0 : printf( "\tlock %lu\n", cnc->lock );
552 0 : printf( "\tsignal %s (%lu)\n", fd_cnc_signal_cstr( cnc->signal, buf ), cnc->signal );
553 :
554 0 : uchar const * a = (uchar const *)fd_cnc_app_laddr_const( cnc );
555 0 : ulong app_sz;
556 0 : for( app_sz=cnc->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
557 0 : ulong off = 0UL;
558 0 : printf( "\tapp %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
559 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
560 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
561 0 : for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
562 0 : printf( "\t %04lx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
563 0 : (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
564 0 : (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
565 0 : if( off<cnc->app_sz ) printf( "\t ... snip (all remaining are zero) ...\n" );
566 0 : }
567 :
568 0 : fd_wksp_unmap( fd_cnc_leave( cnc ) );
569 :
570 0 : FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shcnc, verbose ));
571 0 : SHIFT( 2 );
572 :
573 0 : } else if( !strcmp( cmd, "signal-cnc" ) ) {
574 :
575 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
576 :
577 0 : char const * _shcnc = argv[0];
578 0 : ulong signal = fd_cstr_to_cnc_signal( argv[1] );
579 :
580 0 : char buf[ FD_CNC_SIGNAL_CSTR_BUF_MAX ];
581 :
582 0 : if( FD_UNLIKELY( signal<FD_CNC_SIGNAL_HALT ) )
583 0 : FD_LOG_ERR(( "%i: %s: invalid signal %s (%lu) to send\n\tDo %s help for help",
584 0 : cnt, cmd, fd_cnc_signal_cstr( signal, buf ), signal, bin ));
585 :
586 0 : void * shcnc = fd_wksp_map( _shcnc );
587 0 : if( FD_UNLIKELY( !shcnc ) )
588 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
589 :
590 0 : fd_cnc_t * cnc = fd_cnc_join( shcnc );
591 0 : if( FD_UNLIKELY( !cnc ) )
592 0 : FD_LOG_ERR(( "%i: %s: fd_cnc_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
593 :
594 0 : int err = fd_cnc_open( cnc );
595 0 : if( FD_UNLIKELY( err ) )
596 0 : FD_LOG_ERR(( "%i: %s: fd_cnc_open( \"%s\" ) failed (%i-%s)\n\tDo %s help for help",
597 0 : cnt, cmd, _shcnc, err, fd_cnc_strerror( err ), bin ));
598 :
599 0 : fd_cnc_signal( cnc, signal );
600 :
601 0 : ulong response = fd_cnc_wait( cnc, signal, LONG_MAX, NULL );
602 0 : printf( "%s\n", fd_cnc_signal_cstr( response, buf ) );
603 :
604 0 : fd_cnc_close( cnc );
605 :
606 0 : fd_wksp_unmap( fd_cnc_leave( cnc ) );
607 :
608 0 : FD_LOG_NOTICE(( "%i: %s %s %s: success", cnt, cmd, _shcnc, fd_cnc_signal_cstr( signal, buf ) ));
609 0 : SHIFT( 2 );
610 :
611 0 : } else if( !strcmp( cmd, "new-tcache" ) ) {
612 :
613 0 : if( FD_UNLIKELY( argc<3 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
614 :
615 0 : char const * _wksp = argv[0];
616 0 : ulong depth = fd_cstr_to_ulong( argv[1] );
617 0 : ulong map_cnt = fd_cstr_to_ulong( argv[2] );
618 :
619 0 : ulong align = fd_tcache_align();
620 0 : ulong footprint = fd_tcache_footprint( depth, map_cnt );
621 0 : if( FD_UNLIKELY( !footprint ) ) {
622 0 : FD_LOG_ERR(( "%i: %s: bad depth (%lu) and/or map_cnt (%lu)\n\tDo %s help for help", cnt, cmd, depth, map_cnt, bin ));
623 0 : }
624 :
625 0 : fd_wksp_t * wksp = fd_wksp_attach( _wksp );
626 0 : if( FD_UNLIKELY( !wksp ) ) {
627 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
628 0 : }
629 :
630 0 : ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
631 0 : if( FD_UNLIKELY( !gaddr ) ) {
632 0 : fd_wksp_detach( wksp );
633 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
634 0 : cnt, cmd, _wksp, align, footprint, tag, bin ));
635 0 : }
636 :
637 0 : void * shmem = fd_wksp_laddr( wksp, gaddr );
638 0 : if( FD_UNLIKELY( !shmem ) ) {
639 0 : fd_wksp_free( wksp, gaddr );
640 0 : fd_wksp_detach( wksp );
641 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
642 0 : }
643 :
644 0 : void * _tcache = fd_tcache_new( shmem, depth, map_cnt );
645 0 : if( FD_UNLIKELY( !_tcache ) ) {
646 0 : fd_wksp_free( wksp, gaddr );
647 0 : fd_wksp_detach( wksp );
648 0 : FD_LOG_ERR(( "%i: %s: fd_tcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
649 0 : cnt, cmd, _wksp, gaddr, depth, map_cnt, bin ));
650 0 : }
651 :
652 0 : char buf[ FD_WKSP_CSTR_MAX ];
653 0 : printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
654 :
655 0 : fd_wksp_detach( wksp );
656 :
657 0 : FD_LOG_NOTICE(( "%i: %s %s %lu %lu: success", cnt, cmd, _wksp, depth, map_cnt ));
658 0 : SHIFT( 3 );
659 :
660 0 : } else if( !strcmp( cmd, "delete-tcache" ) ) {
661 :
662 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
663 :
664 0 : char const * gaddr = argv[0];
665 :
666 0 : void * _tcache = fd_wksp_map( gaddr );
667 0 : if( FD_UNLIKELY( !_tcache ) )
668 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
669 0 : if( FD_UNLIKELY( !fd_tcache_delete( _tcache ) ) )
670 0 : FD_LOG_ERR(( "%i: %s: fd_tcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
671 0 : fd_wksp_unmap( _tcache );
672 :
673 0 : fd_wksp_cstr_free( gaddr );
674 :
675 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, gaddr ));
676 0 : SHIFT( 1 );
677 :
678 0 : } else if( !strcmp( cmd, "query-tcache" ) ) {
679 :
680 0 : if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
681 :
682 0 : char const * gaddr = argv[0];
683 0 : int verbose = fd_cstr_to_int( argv[1] );
684 :
685 0 : void * _tcache = fd_wksp_map( gaddr );
686 0 : if( FD_UNLIKELY( !_tcache ) )
687 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
688 :
689 0 : fd_tcache_t * tcache = fd_tcache_join( _tcache );
690 0 : if( FD_UNLIKELY( !tcache ) )
691 0 : FD_LOG_ERR(( "%i: %s: fd_tcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
692 :
693 0 : printf( "tcache %s\n", gaddr );
694 0 : printf( "\tdepth %lu\n", tcache->depth );
695 0 : printf( "\tmap_cnt %lu\n", tcache->map_cnt );
696 :
697 0 : fd_wksp_unmap( fd_tcache_leave( tcache ) );
698 :
699 0 : FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, gaddr, verbose ));
700 0 : SHIFT( 2 );
701 :
702 0 : } else if( !strcmp( cmd, "reset-tcache" ) ) {
703 :
704 0 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
705 :
706 0 : char const * gaddr = argv[0];
707 :
708 0 : void * _tcache = fd_wksp_map( gaddr );
709 0 : if( FD_UNLIKELY( !_tcache ) )
710 0 : FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
711 :
712 0 : fd_tcache_t * tcache = fd_tcache_join( _tcache );
713 0 : if( FD_UNLIKELY( !tcache ) )
714 0 : FD_LOG_ERR(( "%i: %s: fd_tcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
715 :
716 0 : fd_tcache_reset( fd_tcache_ring_laddr( tcache ), fd_tcache_depth ( tcache ),
717 0 : fd_tcache_map_laddr ( tcache ), fd_tcache_map_cnt( tcache ) );
718 :
719 0 : fd_wksp_unmap( fd_tcache_leave( tcache ) );
720 :
721 0 : FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, gaddr ));
722 0 : SHIFT( 1 );
723 :
724 0 : } else {
725 :
726 0 : FD_LOG_ERR(( "%i: %s: unknown command\n\t"
727 0 : "Do %s help for help", cnt, cmd, bin ));
728 :
729 0 : }
730 0 : cnt++;
731 0 : }
732 :
733 0 : if( FD_UNLIKELY( cnt<1 ) ) FD_LOG_NOTICE(( "processed %i commands\n\tDo %s help for help", cnt, bin ));
734 0 : else FD_LOG_NOTICE(( "processed %i commands", cnt ));
735 :
736 0 : # undef SHIFT
737 0 : fd_halt();
738 0 : return 0;
739 0 : }
740 :
741 : #else
742 :
743 : int
744 : main( int argc,
745 : char ** argv ) {
746 : fd_boot( &argc, &argv );
747 : if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "No arguments" ));
748 : if( FD_UNLIKELY( argc>1 ) ) FD_LOG_ERR(( "fd_tango_ctl not supported on this platform" ));
749 : FD_LOG_NOTICE(( "processed 0 commands" ));
750 : fd_halt();
751 : return 0;
752 : }
753 :
754 : #endif
755 :
|