xref: /aosp_15_r20/external/stressapptest/src/os_factory.cc (revision 424fb153c814cbcb3e8904974796228774b3229a)
1*424fb153SAndroid Build Coastguard Worker // Copyright 2006 Google Inc. All Rights Reserved.
2*424fb153SAndroid Build Coastguard Worker 
3*424fb153SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*424fb153SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*424fb153SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*424fb153SAndroid Build Coastguard Worker 
7*424fb153SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
8*424fb153SAndroid Build Coastguard Worker 
9*424fb153SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*424fb153SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*424fb153SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*424fb153SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*424fb153SAndroid Build Coastguard Worker // limitations under the License.
14*424fb153SAndroid Build Coastguard Worker 
15*424fb153SAndroid Build Coastguard Worker // This file generates an OS interface class consistant with the
16*424fb153SAndroid Build Coastguard Worker // current machine type. No machine type detection is currently done.
17*424fb153SAndroid Build Coastguard Worker 
18*424fb153SAndroid Build Coastguard Worker #include <stdlib.h>
19*424fb153SAndroid Build Coastguard Worker #include <stdio.h>
20*424fb153SAndroid Build Coastguard Worker #include <sys/ioctl.h>
21*424fb153SAndroid Build Coastguard Worker #include <string.h>
22*424fb153SAndroid Build Coastguard Worker 
23*424fb153SAndroid Build Coastguard Worker #include <map>
24*424fb153SAndroid Build Coastguard Worker #include <string>
25*424fb153SAndroid Build Coastguard Worker 
26*424fb153SAndroid Build Coastguard Worker #include "os.h"
27*424fb153SAndroid Build Coastguard Worker 
28*424fb153SAndroid Build Coastguard Worker 
29*424fb153SAndroid Build Coastguard Worker // Select the proper OS and hardware interface.
OsLayerFactory(const std::map<std::string,std::string> & options)30*424fb153SAndroid Build Coastguard Worker OsLayer *OsLayerFactory(const std::map<std::string, std::string> &options) {
31*424fb153SAndroid Build Coastguard Worker   OsLayer *os = 0;
32*424fb153SAndroid Build Coastguard Worker   os = new OsLayer();
33*424fb153SAndroid Build Coastguard Worker 
34*424fb153SAndroid Build Coastguard Worker   // Check for memory allocation failure.
35*424fb153SAndroid Build Coastguard Worker   if (!os) {
36*424fb153SAndroid Build Coastguard Worker     logprintf(0, "Process Error: Can't allocate memory\n");
37*424fb153SAndroid Build Coastguard Worker     return 0;
38*424fb153SAndroid Build Coastguard Worker   }
39*424fb153SAndroid Build Coastguard Worker   return os;
40*424fb153SAndroid Build Coastguard Worker }
41