29
29
nitems(graphics_libs_compat))
30
30
31
31
static int select_libraries (struct error * , void * , const char * , const char * );
32
- static int find_library_paths (struct error * , struct nvc_driver_info * , int32_t , const char * , const char * const [], size_t );
32
+ static int find_library_paths (struct error * , struct nvc_driver_info * , const char * , const char * const [], size_t );
33
33
static int find_binary_paths (struct error * , struct nvc_driver_info * , const char * const [], size_t );
34
34
static int find_device_node (struct error * , const char * , struct nvc_device_node * );
35
35
static int find_ipc_path (struct error * , const char * , char * * );
@@ -148,7 +148,7 @@ select_libraries(struct error *err, void *ptr, const char *orig_path, const char
148
148
}
149
149
150
150
static int
151
- find_library_paths (struct error * err , struct nvc_driver_info * info , int32_t flags ,
151
+ find_library_paths (struct error * err , struct nvc_driver_info * info ,
152
152
const char * ldcache , const char * const libs [], size_t size )
153
153
{
154
154
struct ldcache ld ;
@@ -166,15 +166,13 @@ find_library_paths(struct error *err, struct nvc_driver_info *info, int32_t flag
166
166
info -> libs , info -> nlibs , select_libraries , info ) < 0 )
167
167
goto fail ;
168
168
169
- if (flags & OPT_COMPAT32 ) {
170
- info -> nlibs32 = size ;
171
- info -> libs32 = array_new (err , size );
172
- if (info -> libs32 == NULL )
173
- goto fail ;
174
- if (ldcache_resolve (& ld , LIB32_ARCH , libs ,
175
- info -> libs32 , info -> nlibs32 , select_libraries , info ) < 0 )
176
- goto fail ;
177
- }
169
+ info -> nlibs32 = size ;
170
+ info -> libs32 = array_new (err , size );
171
+ if (info -> libs32 == NULL )
172
+ goto fail ;
173
+ if (ldcache_resolve (& ld , LIB32_ARCH , libs ,
174
+ info -> libs32 , info -> nlibs32 , select_libraries , info ) < 0 )
175
+ goto fail ;
178
176
rv = 0 ;
179
177
180
178
fail :
@@ -267,24 +265,17 @@ lookup_libraries(struct error *err, struct nvc_driver_info *info, int32_t flags,
267
265
const char * libs [MAX_LIBS ];
268
266
const char * * ptr = libs ;
269
267
270
- if (flags & OPT_UTILITY_LIBS )
271
- ptr = array_append (ptr , utility_libs , nitems (utility_libs ));
272
- if (flags & OPT_COMPUTE_LIBS )
273
- ptr = array_append (ptr , compute_libs , nitems (compute_libs ));
274
- if (flags & OPT_VIDEO_LIBS )
275
- ptr = array_append (ptr , video_libs , nitems (video_libs ));
276
- if (flags & OPT_GRAPHICS_LIBS ) {
277
- ptr = array_append (ptr , graphics_libs , nitems (graphics_libs ));
278
- if (flags & OPT_NO_GLVND )
279
- ptr = array_append (ptr , graphics_libs_compat , nitems (graphics_libs_compat ));
280
- else
281
- ptr = array_append (ptr , graphics_libs_glvnd , nitems (graphics_libs_glvnd ));
282
- }
268
+ ptr = array_append (ptr , utility_libs , nitems (utility_libs ));
269
+ ptr = array_append (ptr , compute_libs , nitems (compute_libs ));
270
+ ptr = array_append (ptr , video_libs , nitems (video_libs ));
271
+ ptr = array_append (ptr , graphics_libs , nitems (graphics_libs ));
272
+ if (flags & OPT_NO_GLVND )
273
+ ptr = array_append (ptr , graphics_libs_compat , nitems (graphics_libs_compat ));
274
+ else
275
+ ptr = array_append (ptr , graphics_libs_glvnd , nitems (graphics_libs_glvnd ));
283
276
284
- if (flags & (OPT_UTILITY_LIBS |OPT_COMPUTE_LIBS |OPT_VIDEO_LIBS |OPT_GRAPHICS_LIBS )) {
285
- if (find_library_paths (err , info , flags , ldcache , libs , (size_t )(ptr - libs )) < 0 )
286
- return (-1 );
287
- }
277
+ if (find_library_paths (err , info , ldcache , libs , (size_t )(ptr - libs )) < 0 )
278
+ return (-1 );
288
279
289
280
for (size_t i = 0 ; info -> libs != NULL && i < info -> nlibs ; ++ i ) {
290
281
if (info -> libs [i ] == NULL )
@@ -305,15 +296,12 @@ lookup_binaries(struct error *err, struct nvc_driver_info *info, int32_t flags)
305
296
const char * bins [MAX_BINS ];
306
297
const char * * ptr = bins ;
307
298
308
- if (flags & OPT_UTILITY_BINS )
309
- ptr = array_append (ptr , utility_bins , nitems (utility_bins ));
310
- if ((flags & OPT_COMPUTE_BINS ) && !(flags & OPT_NO_MPS ))
299
+ ptr = array_append (ptr , utility_bins , nitems (utility_bins ));
300
+ if (!(flags & OPT_NO_MPS ))
311
301
ptr = array_append (ptr , compute_bins , nitems (compute_bins ));
312
302
313
- if (flags & (OPT_UTILITY_BINS |OPT_COMPUTE_BINS )) {
314
- if (find_binary_paths (err , info , bins , (size_t )(ptr - bins )) < 0 )
315
- return (-1 );
316
- }
303
+ if (find_binary_paths (err , info , bins , (size_t )(ptr - bins )) < 0 )
304
+ return (-1 );
317
305
318
306
for (size_t i = 0 ; info -> bins != NULL && i < info -> nbins ; ++ i ) {
319
307
if (info -> bins [i ] == NULL )
@@ -365,11 +353,11 @@ lookup_ipcs(struct error *err, struct nvc_driver_info *info, int32_t flags)
365
353
if (info -> ipcs == NULL )
366
354
return (-1 );
367
355
368
- if (( flags & OPT_UTILITY_LIBS ) && !(flags & OPT_NO_PERSISTENCED )) {
356
+ if (!(flags & OPT_NO_PERSISTENCED )) {
369
357
if (find_ipc_path (err , NV_PERSISTENCED_SOCKET , ptr ++ ) < 0 )
370
358
return (-1 );
371
359
}
372
- if (( flags & OPT_COMPUTE_LIBS ) && !(flags & OPT_NO_MPS )) {
360
+ if (!(flags & OPT_NO_MPS )) {
373
361
if ((mps = secure_getenv ("CUDA_MPS_PIPE_DIRECTORY" )) == NULL )
374
362
mps = NV_MPS_PIPE_DIR ;
375
363
if (find_ipc_path (err , mps , ptr ++ ) < 0 )
@@ -379,6 +367,32 @@ lookup_ipcs(struct error *err, struct nvc_driver_info *info, int32_t flags)
379
367
return (0 );
380
368
}
381
369
370
+ bool
371
+ match_binary_flags (const char * bin , int32_t flags )
372
+ {
373
+ if ((flags & OPT_UTILITY_BINS ) && strmatch (bin , utility_bins , nitems (utility_bins )))
374
+ return (true);
375
+ if ((flags & OPT_COMPUTE_BINS ) && strmatch (bin , compute_bins , nitems (compute_bins )))
376
+ return (true);
377
+ return (false);
378
+ }
379
+
380
+ bool
381
+ match_library_flags (const char * lib , int32_t flags )
382
+ {
383
+ if ((flags & OPT_UTILITY_LIBS ) && strmatch (lib , utility_libs , nitems (utility_libs )))
384
+ return (true);
385
+ if ((flags & OPT_COMPUTE_LIBS ) && strmatch (lib , compute_libs , nitems (compute_libs )))
386
+ return (true);
387
+ if ((flags & OPT_VIDEO_LIBS ) && strmatch (lib , video_libs , nitems (video_libs )))
388
+ return (true);
389
+ if ((flags & OPT_GRAPHICS_LIBS ) && (strmatch (lib , graphics_libs , nitems (graphics_libs )) ||
390
+ strmatch (lib , graphics_libs_glvnd , nitems (graphics_libs_glvnd )) ||
391
+ strmatch (lib , graphics_libs_compat , nitems (graphics_libs_compat ))))
392
+ return (true);
393
+ return (false);
394
+ }
395
+
382
396
struct nvc_driver_info *
383
397
nvc_driver_info_new (struct nvc_context * ctx , const char * opts )
384
398
{
0 commit comments