@@ -9298,13 +9298,6 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9298
9298
return -1;
9299
9299
}
9300
9300
9301
- #ifdef ESP8266
9302
- if((nrbytes % 4) != 0) {
9303
- Serial.println("Rules AST not 4 byte aligned!");
9304
- exit(-1);
9305
- }
9306
- #endif
9307
-
9308
9301
/*LCOV_EXCL_START*/
9309
9302
#ifdef ESP8266
9310
9303
obj->timestamp->second = micros();
@@ -9319,14 +9312,12 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9319
9312
#endif
9320
9313
/*LCOV_EXCL_STOP*/
9321
9314
9322
-
9323
- /*LCOV_EXCL_START*/
9324
9315
#ifdef ESP8266
9325
- obj->timestamp->first = micros();
9326
- #else
9327
- clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->first);
9316
+ if((nrbytes % 4) != 0) {
9317
+ Serial.println("Rules AST not 4 byte aligned!");
9318
+ exit(-1);
9319
+ }
9328
9320
#endif
9329
- /*LCOV_EXCL_STOP*/
9330
9321
9331
9322
{
9332
9323
{
@@ -9376,6 +9367,14 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9376
9367
mempool->len += nrbytes;
9377
9368
memset(obj->ast.buffer, 0, nrbytes);
9378
9369
9370
+ /*LCOV_EXCL_START*/
9371
+ #ifdef ESP8266
9372
+ obj->timestamp->first = micros();
9373
+ #else
9374
+ clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->first);
9375
+ #endif
9376
+ /*LCOV_EXCL_STOP*/
9377
+
9379
9378
if(rule_parse((char **)&input->payload, obj) == -1) {
9380
9379
vm_cache_gc();
9381
9380
FREE((*rules)[*nrrules-1]->timestamp);
@@ -9387,27 +9386,6 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9387
9386
return -1;
9388
9387
}
9389
9388
9390
- #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9391
- if(is_mmu_input == 1) {
9392
- mmu_set_uint16(&input->len, mmu_get_uint16(&input->len) + newlen);
9393
- if(mmu_get_uint8(&((char *)input->payload)[newlen]) == 0) {
9394
- mmu_set_uint16(&input->len, mmu_get_uint16(&input->len) + 1);
9395
- }
9396
- mmu_set_uint16(&input->tot_len, mmu_get_uint16(&input->tot_len) - newlen);
9397
- } else {
9398
- #endif
9399
- input->len += newlen;
9400
- if(newlen < input->tot_len) {
9401
- if(((unsigned char *)input->payload)[newlen] == 0) {
9402
- input->len += 1;
9403
- }
9404
- }
9405
- input->tot_len -= newlen;
9406
- }
9407
- #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9408
- }
9409
- #endif
9410
-
9411
9389
/*LCOV_EXCL_START*/
9412
9390
#ifdef ESP8266
9413
9391
obj->timestamp->second = micros();
@@ -9434,6 +9412,28 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9434
9412
#endif
9435
9413
/*LCOV_EXCL_STOP*/
9436
9414
9415
+ #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9416
+ if(is_mmu_input == 1) {
9417
+ mmu_set_uint16(&input->len, mmu_get_uint16(&input->len) + newlen);
9418
+ if(mmu_get_uint8(&((char *)input->payload)[newlen]) == 0) {
9419
+ mmu_set_uint16(&input->len, mmu_get_uint16(&input->len) + 1);
9420
+ }
9421
+ mmu_set_uint16(&input->tot_len, mmu_get_uint16(&input->tot_len) - newlen);
9422
+ } else {
9423
+ #endif
9424
+ input->len += newlen;
9425
+ if(newlen < input->tot_len) {
9426
+ if(((unsigned char *)input->payload)[newlen] == 0) {
9427
+ input->len += 1;
9428
+ }
9429
+ }
9430
+ input->tot_len -= newlen;
9431
+ }
9432
+ #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9433
+ }
9434
+ #endif
9435
+
9436
+
9437
9437
/*LCOV_EXCL_START*/
9438
9438
#ifdef DEBUG
9439
9439
#ifndef ESP8266
@@ -9443,14 +9443,6 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9443
9443
print_tree(obj);
9444
9444
#endif
9445
9445
#endif
9446
- /*LCOV_EXCL_STOP*/
9447
-
9448
- /*LCOV_EXCL_START*/
9449
- #ifdef ESP8266
9450
- obj->timestamp->first = micros();
9451
- #else
9452
- clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->first);
9453
- #endif
9454
9446
/*LCOV_EXCL_STOP*/
9455
9447
9456
9448
/*
@@ -9551,6 +9543,14 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9551
9543
9552
9544
memset(obj->varstack->buffer, 0, suggested_varstack_size);
9553
9545
9546
+ /*LCOV_EXCL_START*/
9547
+ #ifdef ESP8266
9548
+ obj->timestamp->first = micros();
9549
+ #else
9550
+ clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->first);
9551
+ #endif
9552
+ /*LCOV_EXCL_STOP*/
9553
+
9554
9554
/*
9555
9555
* The rule_run function will return -2
9556
9556
* if the varstack is too small
@@ -9568,6 +9568,37 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9568
9568
}
9569
9569
}
9570
9570
9571
+ /*LCOV_EXCL_START*/
9572
+ #ifdef ESP8266
9573
+ obj->timestamp->second = micros();
9574
+
9575
+ #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9576
+ if(obj >= (void *)MMU_SEC_HEAP) {
9577
+ logprintf_P(F("rule #%d was executed in %d microseconds"), mmu_get_uint8(&obj->nr), obj->timestamp->second - obj->timestamp->first);
9578
+ } else {
9579
+ #endif
9580
+ logprintf_P(F("rule #%d was executed in %d microseconds"), obj->nr, obj->timestamp->second - obj->timestamp->first);
9581
+ #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9582
+ }
9583
+ if(&obj->ast >= (void *)MMU_SEC_HEAP) {
9584
+ logprintf_P(F("bytecode is %d bytes"), mmu_get_uint16(&obj->ast.nrbytes));
9585
+ } else {
9586
+ #endif
9587
+ logprintf_P(F("bytecode is %d bytes"), obj->ast.nrbytes);
9588
+ #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9589
+ }
9590
+ #endif
9591
+ #else
9592
+ clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->second);
9593
+
9594
+ printf("rule #%d was executed in %.6f seconds\n", obj->nr,
9595
+ ((double)obj->timestamp->second.tv_sec + 1.0e-9*obj->timestamp->second.tv_nsec) -
9596
+ ((double)obj->timestamp->first.tv_sec + 1.0e-9*obj->timestamp->first.tv_nsec));
9597
+
9598
+ printf("bytecode is %d bytes\n", obj->ast.nrbytes);
9599
+ #endif
9600
+ /*LCOV_EXCL_STOP*/
9601
+
9571
9602
/*
9572
9603
* If a previous varstack was bigger than the current
9573
9604
* varstack, use the previous varstack size. This will
@@ -9608,37 +9639,6 @@ int8_t rule_initialize(struct pbuf *input, struct rules_t ***rules, uint8_t *nrr
9608
9639
}
9609
9640
#endif
9610
9641
9611
- /*LCOV_EXCL_START*/
9612
- #ifdef ESP8266
9613
- obj->timestamp->second = micros();
9614
-
9615
- #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9616
- if(obj >= (void *)MMU_SEC_HEAP) {
9617
- logprintf_P(F("rule #%d was executed in %d microseconds"), mmu_get_uint8(&obj->nr), obj->timestamp->second - obj->timestamp->first);
9618
- } else {
9619
- #endif
9620
- logprintf_P(F("rule #%d was executed in %d microseconds"), obj->nr, obj->timestamp->second - obj->timestamp->first);
9621
- #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9622
- }
9623
- if(&obj->ast >= (void *)MMU_SEC_HEAP) {
9624
- logprintf_P(F("bytecode is %d bytes"), mmu_get_uint16(&obj->ast.nrbytes));
9625
- } else {
9626
- #endif
9627
- logprintf_P(F("bytecode is %d bytes"), obj->ast.nrbytes);
9628
- #if (!defined(NON32XFER_HANDLER) && defined(MMU_SEC_HEAP)) || defined(COVERALLS)
9629
- }
9630
- #endif
9631
- #else
9632
- clock_gettime(CLOCK_MONOTONIC, &obj->timestamp->second);
9633
-
9634
- printf("rule #%d was executed in %.6f seconds\n", obj->nr,
9635
- ((double)obj->timestamp->second.tv_sec + 1.0e-9*obj->timestamp->second.tv_nsec) -
9636
- ((double)obj->timestamp->first.tv_sec + 1.0e-9*obj->timestamp->first.tv_nsec));
9637
-
9638
- printf("bytecode is %d bytes\n", obj->ast.nrbytes);
9639
- #endif
9640
- /*LCOV_EXCL_STOP*/
9641
-
9642
9642
assert(nrcache == 0);
9643
9643
9644
9644
return 0;
0 commit comments