*Most* oils are "dual rated", meaning that they cover both gasoline and diesel requirements.
Gasoline and diesel oils have different addative packages because the contaminates in the crankcase are different. With a gasoline engine you get a lot of moisture and tar and with a diesel the oil becomes acidic and will collect more carbon.
Many oils will work well in either engine type but it's always best to use an oil specially formulated to the type of engine for optimal life.
You will see things like "API SG/CJ" on the oil container, that means:
API = American Petrolium Industry
SG = Spark ignition, grade "G"
CJ = Compression ignition, grade "J"
The second letter is the grade designator, in alphabetical order, and later = better.