dsp_profile.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2021 Alibaba Group. All rights reserved.
  3. * License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. * not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include "dsp_utils.h"
  21. #include "xrp_rb_file.h"
  22. static profiler* profil_hanlder;
  23. int dsp_profile_init(void* buf,size_t buf_size)
  24. {
  25. if(buf == NULL)
  26. {
  27. return -1;
  28. }
  29. profil_hanlder =buf;
  30. profil_hanlder->read = 0;
  31. profil_hanlder->write = 0;
  32. profil_hanlder->size = buf_size - sizeof(profiler);
  33. return 0;
  34. }
  35. void dsp_profile_entry_add(void*entry_ptr,size_t entry_size)
  36. {
  37. xrp_rb_write((void*)profil_hanlder,entry_ptr,entry_size);
  38. return;
  39. }
  40. void dsp_profile_entry_add_ring(void*entry_ptr,size_t entry_size)
  41. {
  42. size_t wirte_size = xrp_rb_write((void*)profil_hanlder,entry_ptr,entry_size);
  43. if(wirte_size <entry_size)
  44. {
  45. profil_hanlder->read = 0;
  46. profil_hanlder->write = 0;
  47. }
  48. return;
  49. }