debugservices.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "platform.h"
  14. #include "debugservices.hpp"
  15. #define DEBUGSERVICES_VERSION "DEBUGSERVICES 1.0.1"
  16. static const char * EclDefinition =
  17. "export DebugServices := SERVICE\n"
  18. " Sleep(integer millis) : c,time,pure,entrypoint='dsSleep',initFunction='dsInitDebugServices'; \n"
  19. " varstring GetBuildInfo() : c,pure,entrypoint='dsGetBuildInfo',initFunction='dsInitDebugServices';\n"
  20. "END;";
  21. static const char * compatibleVersions[] = {
  22. "DEBUGSERVICES 1.0 [7294888b4271178e0cfda307826d4823]",
  23. "DEBUGSERVICES 1.0.1",
  24. NULL };
  25. DEBUGSERVICES_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  26. {
  27. if (pb->size != sizeof(ECLPluginDefinitionBlock))
  28. return false;
  29. pb->magicVersion = PLUGIN_VERSION;
  30. pb->version = DEBUGSERVICES_VERSION;
  31. pb->moduleName = "lib_debugservices";
  32. pb->ECL = EclDefinition;
  33. pb->flags = PLUGIN_IMPLICIT_MODULE;
  34. pb->description = "DEBUGSERVICES library";
  35. return true;
  36. }
  37. DEBUGSERVICES_API char * DEBUGSERVICES_CALL dsGetBuildInfo(void)
  38. {
  39. return strdup(DEBUGSERVICES_VERSION);
  40. }
  41. //-------------------------------------------------------------------------------------------------------------------------------------------
  42. DEBUGSERVICES_API void DEBUGSERVICES_CALL dsSleep(unsigned milli)
  43. {
  44. #ifdef _WIN32
  45. Sleep(milli);
  46. #else
  47. timespec sleepTime;
  48. if (milli>=1000)
  49. {
  50. sleepTime.tv_sec = milli/1000;
  51. milli %= 1000;
  52. }
  53. else
  54. sleepTime.tv_sec = 0;
  55. sleepTime.tv_nsec = milli * 1000000;
  56. nanosleep(&sleepTime, NULL);
  57. #endif
  58. }