Changeset: 16163c504a2c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/16163c504a2c
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        monetdb5/modules/kernel/alarm.c
Branch: default
Log Message:

Removed alarm.sleep with a BAT argument.


diffs (163 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -3364,11 +3364,6 @@ unsafe pattern alarm.sleep(X_0:any_1):vo
 ALARMsleep;
 Sleep a few milliseconds
 alarm
-sleep
-unsafe pattern alarm.sleep(X_0:bat[:any_1]):bat[:any_1] 
-ALARMsleep;
-Sleep a few milliseconds and return the slept value
-alarm
 time
 unsafe command alarm.time():int 
 ALARMtime;
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -2799,11 +2799,6 @@ unsafe pattern alarm.sleep(X_0:any_1):vo
 ALARMsleep;
 Sleep a few milliseconds
 alarm
-sleep
-unsafe pattern alarm.sleep(X_0:bat[:any_1]):bat[:any_1] 
-ALARMsleep;
-Sleep a few milliseconds and return the slept value
-alarm
 time
 unsafe command alarm.time():int 
 ALARMtime;
diff --git a/monetdb5/modules/kernel/alarm.c b/monetdb5/modules/kernel/alarm.c
--- a/monetdb5/modules/kernel/alarm.c
+++ b/monetdb5/modules/kernel/alarm.c
@@ -38,7 +38,8 @@ ALARMusec(lng *ret)
 
 #define SLEEP_SINGLE(TPE)                                                      
                                        \
        do {                                                                    
                                                        \
-               TPE *res = (TPE*) getArgReference(stk, pci, 0), *msecs = (TPE*) 
getArgReference(stk,pci,1); \
+               TPE *res = getArgReference_##TPE(stk, pci, 0);                  
                \
+               const TPE *msecs = getArgReference_##TPE(stk,pci,1);            
        \
                if (is_##TPE##_nil(*msecs))                                     
                                        \
                        throw(MAL, "alarm.sleep", "NULL values not allowed for 
sleeping time"); \
                if (*msecs < 0)                                                 
                                                \
@@ -47,97 +48,24 @@ ALARMusec(lng *ret)
                *res = *msecs;                                                  
                                                \
        } while (0)
 
-#define SLEEP_MULTI(TPE)                                                       
                                        \
-       do {                                                                    
                                                        \
-               for (i = 0; i < j ; i++) {                                      
                                        \
-                       if (is_##TPE##_nil(bb[i])) {                            
                                \
-                               bat_iterator_end(&bi);                          
                                        \
-                               BBPreclaim(r);                                  
                                                \
-                               BBPunfix(b->batCacheid);                        
                                        \
-                               throw(MAL, "alarm.sleep", "NULL values not 
allowed for sleeping time"); \
-                       }                                                       
                                                                \
-                       if (bb[i] < 0) {                                        
                                                \
-                               bat_iterator_end(&bi);                          
                                        \
-                               BBPreclaim(r);                                  
                                                \
-                               BBPunfix(b->batCacheid);                        
                                        \
-                               throw(MAL, "alarm.sleep", "Cannot sleep for a 
negative time"); \
-                       }                                                       
                                                                \
-               }                                                               
                                                                \
-               for (i = 0; i < j ; i++) {                                      
                                        \
-                       MT_sleep_ms((unsigned int) bb[i]);                      
                                \
-                       rb[i] = bb[i];                                          
                                                \
-               }                                                               
                                                                \
-       } while (0)
-
 static str
 ALARMsleep(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       BAT *r = NULL, *b = NULL;
-       int *restrict rb, *restrict bb, tpe;
-       BUN i, j;
-
        (void) cntxt;
-       if (getArgType(mb, pci, 0) != TYPE_void
-               && isaBatType(getArgType(mb, pci, 1))) {
-               bat *res = getArgReference_bat(stk, pci, 0);
-               bat *bid = getArgReference_bat(stk, pci, 1);
-               tpe = getArgType(mb, pci, 1);
-
-               if (!(b = BATdescriptor(*bid)))
-                       throw(MAL, "alarm.sleep",
-                                 SQLSTATE(HY005) "Cannot access column 
descriptor");
-
-               BATiter bi = bat_iterator(b);
-               j = bi.count;
-               bb = bi.base;
-
-               if (!(r = COLnew(0, tpe, j, TRANSIENT))) {
-                       bat_iterator_end(&bi);
-                       BBPunfix(b->batCacheid);
-                       throw(MAL, "alarm.sleep", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-               }
-               rb = Tloc(r, 0);
-
-               switch (tpe) {
-               case TYPE_bte:
-                       SLEEP_MULTI(bte);
-                       break;
-               case TYPE_sht:
-                       SLEEP_MULTI(sht);
-                       break;
-               case TYPE_int:
-                       SLEEP_MULTI(int);
-                       break;
-               default:{
-                       bat_iterator_end(&bi);
-                       BBPreclaim(r);
-                       BBPunfix(b->batCacheid);
-                       throw(MAL, "alarm.sleep",
-                                 SQLSTATE(42000) "Sleep function not available 
for type %s",
-                                 ATOMname(tpe));
-               }
-               }
-               bat_iterator_end(&bi);
-
-               BBPunfix(b->batCacheid);
-               *res = r->batCacheid;
-               BBPkeepref(r);
-       } else {
-               switch (getArgType(mb, pci, 1)) {
-               case TYPE_bte:
-                       SLEEP_SINGLE(bte);
-                       break;
-               case TYPE_sht:
-                       SLEEP_SINGLE(sht);
-                       break;
-               case TYPE_int:
-                       SLEEP_SINGLE(int);
-                       break;
-               default:
-                       throw(MAL, "alarm.sleep",
-                                 SQLSTATE(42000) "Sleep function not available 
for type %s",
-                                 ATOMname(getArgType(mb, pci, 1)));
-               }
+       switch (getArgType(mb, pci, 1)) {
+       case TYPE_bte:
+               SLEEP_SINGLE(bte);
+               break;
+       case TYPE_sht:
+               SLEEP_SINGLE(sht);
+               break;
+       case TYPE_int:
+               SLEEP_SINGLE(int);
+               break;
+       default:
+               throw(MAL, "alarm.sleep",
+                         SQLSTATE(42000) "Sleep function not available for 
type %s",
+                         ATOMname(getArgType(mb, pci, 1)));
        }
        return MAL_SUCCEED;
 }
@@ -183,7 +111,6 @@ ALARMtime(int *res)
 mel_func alarm_init_funcs[] = {
  pattern("alarm", "sleep", ALARMsleep, true, "Sleep a few milliseconds", 
args(1,2, arg("",void),argany("msecs",1))),
  pattern("alarm", "sleep", ALARMsleep, true, "Sleep a few milliseconds and 
return the slept value", args(1,2, argany("",1),argany("msecs",1))),
- pattern("alarm", "sleep", ALARMsleep, true, "Sleep a few milliseconds and 
return the slept value", args(1,2, batargany("",1),batargany("msecs",1))),
  command("alarm", "usec", ALARMusec, true, "Return time since Jan 1, 1970 in 
microseconds.", args(1,1, arg("",lng))),
  command("alarm", "time", ALARMtime, true, "Return time since program start in 
milliseconds.", args(1,1, arg("",int))),
  command("alarm", "epoch", ALARMepoch, true, "Return time since Jan 1, 1970 in 
seconds.", args(1,1, arg("",int))),
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to