@@ -24,6 +24,37 @@ umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void) {
2424 return NULL ;
2525}
2626
27+ umf_result_t umfDevDaxMemoryProviderParamsCreate (
28+ umf_devdax_memory_provider_params_handle_t * hParams , const char * path ,
29+ size_t size ) {
30+ (void )hParams ;
31+ (void )path ;
32+ (void )size ;
33+ return UMF_RESULT_ERROR_NOT_SUPPORTED ;
34+ }
35+
36+ umf_result_t umfDevDaxMemoryProviderParamsDestroy (
37+ umf_devdax_memory_provider_params_handle_t hParams ) {
38+ (void )hParams ;
39+ return UMF_RESULT_ERROR_NOT_SUPPORTED ;
40+ }
41+
42+ umf_result_t umfDevDaxMemoryProviderParamsSetDeviceDax (
43+ umf_devdax_memory_provider_params_handle_t hParams , const char * path ,
44+ size_t size ) {
45+ (void )hParams ;
46+ (void )path ;
47+ (void )size ;
48+ return UMF_RESULT_ERROR_NOT_SUPPORTED ;
49+ }
50+
51+ umf_result_t umfDevDaxMemoryProviderParamsSetProtection (
52+ umf_devdax_memory_provider_params_handle_t hParams , unsigned protection ) {
53+ (void )hParams ;
54+ (void )protection ;
55+ return UMF_RESULT_ERROR_NOT_SUPPORTED ;
56+ }
57+
2758#else // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
2859
2960#include "base_alloc_global.h"
@@ -44,6 +75,13 @@ typedef struct devdax_memory_provider_t {
4475 unsigned protection ; // combination of OS-specific protection flags
4576} devdax_memory_provider_t ;
4677
78+ // DevDax Memory provider settings struct
79+ typedef struct umf_devdax_memory_provider_params_t {
80+ char * path ;
81+ size_t size ;
82+ unsigned protection ;
83+ } umf_devdax_memory_provider_params_t ;
84+
4785typedef struct devdax_last_native_error_t {
4886 int32_t native_error ;
4987 int errno_value ;
@@ -511,4 +549,99 @@ umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void) {
511549 return & UMF_DEVDAX_MEMORY_PROVIDER_OPS ;
512550}
513551
552+ umf_result_t umfDevDaxMemoryProviderParamsCreate (
553+ umf_devdax_memory_provider_params_handle_t * hParams , const char * path ,
554+ size_t size ) {
555+ if (hParams == NULL ) {
556+ LOG_ERR ("DevDax Memory Provider params handle is NULL" );
557+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
558+ }
559+
560+ if (path == NULL ) {
561+ LOG_ERR ("DevDax path is NULL" );
562+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
563+ }
564+
565+ umf_devdax_memory_provider_params_handle_t params =
566+ umf_ba_global_alloc (sizeof (* params ));
567+ if (params == NULL ) {
568+ LOG_ERR (
569+ "Allocating memory for the DevDax Memory Provider params failed" );
570+ return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
571+ }
572+
573+ params -> path = NULL ;
574+ params -> size = 0 ;
575+ params -> protection = UMF_PROTECTION_READ | UMF_PROTECTION_WRITE ;
576+
577+ umf_result_t res =
578+ umfDevDaxMemoryProviderParamsSetDeviceDax (params , path , size );
579+ if (res != UMF_RESULT_SUCCESS ) {
580+ umf_ba_global_free (params );
581+ return res ;
582+ }
583+
584+ * hParams = params ;
585+
586+ return UMF_RESULT_SUCCESS ;
587+ }
588+
589+ umf_result_t umfDevDaxMemoryProviderParamsDestroy (
590+ umf_devdax_memory_provider_params_handle_t hParams ) {
591+ if (hParams != NULL ) {
592+ umf_ba_global_free (hParams -> path );
593+ umf_ba_global_free (hParams );
594+ }
595+
596+ return UMF_RESULT_SUCCESS ;
597+ }
598+
599+ umf_result_t umfDevDaxMemoryProviderParamsSetDeviceDax (
600+ umf_devdax_memory_provider_params_handle_t hParams , const char * path ,
601+ size_t size ) {
602+ if (hParams == NULL ) {
603+ LOG_ERR ("DevDax Memory Provider params handle is NULL" );
604+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
605+ }
606+
607+ if (path == NULL ) {
608+ LOG_ERR ("DevDax path is NULL" );
609+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
610+ }
611+
612+ size_t path_len = strlen (path );
613+ if (path_len == 0 ) {
614+ LOG_ERR ("DevDax path is empty" );
615+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
616+ }
617+
618+ path_len += 1 ; // for the null terminator
619+ char * new_path = umf_ba_global_alloc (path_len );
620+ if (new_path == NULL ) {
621+ LOG_ERR ("Allocating memory for the DevDax path failed" );
622+ return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
623+ }
624+
625+ strncpy (new_path , path , path_len );
626+
627+ umf_ba_global_free (hParams -> path );
628+
629+ hParams -> path = new_path ;
630+ hParams -> size = size ;
631+
632+ return UMF_RESULT_SUCCESS ;
633+ }
634+
635+ umf_result_t umfDevDaxMemoryProviderParamsSetProtection (
636+ umf_devdax_memory_provider_params_handle_t hParams , unsigned protection ) {
637+ if (hParams == NULL ) {
638+ LOG_ERR ("DevDax Memory Provider params handle is NULL" );
639+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
640+ }
641+
642+ hParams -> protection = protection ;
643+
644+ return UMF_RESULT_SUCCESS ;
645+ }
646+
514647#endif // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
0 commit comments